< prev index next >

src/java.base/linux/classes/sun/nio/ch/EPoll.java

Print this page
rev 49242 : [mq]: selector-cleanup
   1 /*
   2  * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  42      *     void *ptr;
  43      *     int fd;
  44      *     __uint32_t u32;
  45      *     __uint64_t u64;
  46      *  } epoll_data_t;
  47      *
  48      * struct epoll_event {
  49      *     __uint32_t events;
  50      *     epoll_data_t data;
  51      * }
  52      */
  53     private static final int SIZEOF_EPOLLEVENT   = eventSize();
  54     private static final int OFFSETOF_EVENTS     = eventsOffset();
  55     private static final int OFFSETOF_FD         = dataOffset();
  56 
  57     // opcodes
  58     static final int EPOLL_CTL_ADD  = 1;
  59     static final int EPOLL_CTL_DEL  = 2;
  60     static final int EPOLL_CTL_MOD  = 3;
  61 




  62     // flags
  63     static final int EPOLLONESHOT   = (1 << 30);
  64 
  65     /**
  66      * Allocates a poll array to handle up to {@code count} events.
  67      */
  68     static long allocatePollArray(int count) {
  69         return unsafe.allocateMemory(count * SIZEOF_EPOLLEVENT);
  70     }
  71 
  72     /**
  73      * Free a poll array
  74      */
  75     static void freePollArray(long address) {
  76         unsafe.freeMemory(address);
  77     }
  78 
  79     /**
  80      * Returns event[i];
  81      */


   1 /*
   2  * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  42      *     void *ptr;
  43      *     int fd;
  44      *     __uint32_t u32;
  45      *     __uint64_t u64;
  46      *  } epoll_data_t;
  47      *
  48      * struct epoll_event {
  49      *     __uint32_t events;
  50      *     epoll_data_t data;
  51      * }
  52      */
  53     private static final int SIZEOF_EPOLLEVENT   = eventSize();
  54     private static final int OFFSETOF_EVENTS     = eventsOffset();
  55     private static final int OFFSETOF_FD         = dataOffset();
  56 
  57     // opcodes
  58     static final int EPOLL_CTL_ADD  = 1;
  59     static final int EPOLL_CTL_DEL  = 2;
  60     static final int EPOLL_CTL_MOD  = 3;
  61 
  62     // events
  63     static final int EPOLLIN   = 0x1;
  64     static final int EPOLLOUT  = 0x4;
  65 
  66     // flags
  67     static final int EPOLLONESHOT   = (1 << 30);
  68 
  69     /**
  70      * Allocates a poll array to handle up to {@code count} events.
  71      */
  72     static long allocatePollArray(int count) {
  73         return unsafe.allocateMemory(count * SIZEOF_EPOLLEVENT);
  74     }
  75 
  76     /**
  77      * Free a poll array
  78      */
  79     static void freePollArray(long address) {
  80         unsafe.freeMemory(address);
  81     }
  82 
  83     /**
  84      * Returns event[i];
  85      */


< prev index next >