< prev index next >

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

Print this page




  88         // open epoll
  89         this.epfd = epollCreate();
  90 
  91         // create socket pair for wakeup mechanism
  92         int[] sv = new int[2];
  93         try {
  94             socketpair(sv);
  95             // register one end with epoll
  96             epollCtl(epfd, EPOLL_CTL_ADD, sv[0], Net.POLLIN);
  97         } catch (IOException x) {
  98             close0(epfd);
  99             throw x;
 100         }
 101         this.sp = sv;
 102 
 103         // allocate the poll array
 104         this.address = allocatePollArray(MAX_EPOLL_EVENTS);
 105 
 106         // create the queue and offer the special event to ensure that the first
 107         // threads polls
 108         this.queue = new ArrayBlockingQueue<Event>(MAX_EPOLL_EVENTS);
 109         this.queue.offer(NEED_TO_POLL);
 110     }
 111 
 112     EPollPort start() {
 113         startThreads(new EventHandlerTask());
 114         return this;
 115     }
 116 
 117     /**
 118      * Release all resources
 119      */
 120     private void implClose() {
 121         synchronized (this) {
 122             if (closed)
 123                 return;
 124             closed = true;
 125         }
 126         freePollArray(address);
 127         close0(sp[0]);
 128         close0(sp[1]);




  88         // open epoll
  89         this.epfd = epollCreate();
  90 
  91         // create socket pair for wakeup mechanism
  92         int[] sv = new int[2];
  93         try {
  94             socketpair(sv);
  95             // register one end with epoll
  96             epollCtl(epfd, EPOLL_CTL_ADD, sv[0], Net.POLLIN);
  97         } catch (IOException x) {
  98             close0(epfd);
  99             throw x;
 100         }
 101         this.sp = sv;
 102 
 103         // allocate the poll array
 104         this.address = allocatePollArray(MAX_EPOLL_EVENTS);
 105 
 106         // create the queue and offer the special event to ensure that the first
 107         // threads polls
 108         this.queue = new ArrayBlockingQueue<>(MAX_EPOLL_EVENTS);
 109         this.queue.offer(NEED_TO_POLL);
 110     }
 111 
 112     EPollPort start() {
 113         startThreads(new EventHandlerTask());
 114         return this;
 115     }
 116 
 117     /**
 118      * Release all resources
 119      */
 120     private void implClose() {
 121         synchronized (this) {
 122             if (closed)
 123                 return;
 124             closed = true;
 125         }
 126         freePollArray(address);
 127         close0(sp[0]);
 128         close0(sp[1]);


< prev index next >