void updateRegistrations() throws IOException {
    // Populate pollfd array with updated masks
    synchronized (updateList) {
      while (updateList.size() > 0) {
        // We have to insert a dummy node in between each
        // real update to use POLLREMOVE on the fd first because
        // otherwise the changes are simply OR'd together
        int index = 0;
        Updator u = null;
        while ((u = updateList.poll()) != null) {
          // First add pollfd struct to clear out this fd
          putPollFD(updatePollArray, index, u.fd, POLLREMOVE);
          index++;
          // Now add pollfd to update this fd, if necessary
          if (u.mask != POLLREMOVE) {
            putPollFD(updatePollArray, index, u.fd, (short) u.mask);
            index++;
          }

          // Check against the max update size; these are
          // all we will process. Valid index ranges from 0 to
          // (MAX_UPDATE_SIZE - 1) and we can use up to 2 per loop
          if (index > MAX_UPDATE_SIZE - 2) break;
        }
        // Register the changes with /dev/poll
        registerMultiple(wfd, updatePollArray.address(), index);
      }
    }
  }
예제 #2
0
 // Grows the pollfd array to new size
 void grow(int newSize) {
   PollArrayWrapper temp = new PollArrayWrapper(newSize);
   for (int i = 0; i < size; i++) replaceEntry(this, i, temp, i);
   pollArray.free();
   pollArray = temp.pollArray;
   this.size = temp.size;
   pollArrayAddress = pollArray.address();
 }
예제 #3
0
 PollArrayWrapper(int newSize) {
   int allocationSize = newSize * SIZE_POLLFD;
   pollArray = new AllocatedNativeObject(allocationSize, true);
   pollArrayAddress = pollArray.address();
   this.size = newSize;
 }
예제 #4
0
 KQueueArrayWrapper() {
   int allocationSize = SIZEOF_KEVENT * NUM_KEVENTS;
   keventArray = new AllocatedNativeObject(allocationSize, true);
   keventArrayAddress = keventArray.address();
   kq = init();
 }