void add(long value) { checkSize(); PlatformDependent.putLong(memoryOffset(size++), value); }
void remove(AbstractKQueueChannel ch) throws IOException { assert inEventLoop(); if (ch.jniSelfPtr == 0) { return; } jniChannelPointers.add(ch.jniSelfPtr); ch.jniSelfPtr = 0; }
private void deleteJniChannelPointers() { if (!jniChannelPointers.isEmpty()) { deleteGlobalRefs(jniChannelPointers.memoryAddress(), jniChannelPointers.memoryAddressEnd()); jniChannelPointers.clear(); } }
void add(long value) { reallocIfNeeded(); if (PlatformDependent.hasUnsafe()) { PlatformDependent.putLong(memoryOffset(size), value); } else { memory.putLong(idx(size), value); } ++size; }
long memoryAddressEnd() { return memoryOffset(size); }
private void checkSize() { if (size == capacity) { realloc(); } }
@Override protected void cleanup() { try { try { kqueueFd.close(); } catch (IOException e) { logger.warn("Failed to close the kqueue fd.", e); } } finally { // Cleanup all native memory! // The JNI channel pointers should already be deleted because we should wait on kevent before this method, // but lets just be sure we cleanup native memory. deleteJniChannelPointers(); jniChannelPointers.free(); changeList.free(); eventList.free(); } }
KQueueEventLoop(EventLoopGroup parent, Executor executor, int maxEvents, SelectStrategy strategy, RejectedExecutionHandler rejectedExecutionHandler) { super(parent, executor, false, DEFAULT_MAX_PENDING_TASKS, rejectedExecutionHandler); selectStrategy = ObjectUtil.checkNotNull(strategy, "strategy"); this.kqueueFd = Native.newKQueue(); if (maxEvents == 0) { allowGrowing = true; maxEvents = 4096; } else { allowGrowing = false; } changeList = new KQueueEventArray(maxEvents); eventList = new KQueueEventArray(maxEvents); jniChannelPointers = new NativeLongArray(4096); int result = Native.keventAddUserEvent(kqueueFd.intValue(), KQUEUE_WAKE_UP_IDENT); if (result < 0) { cleanup(); throw new IllegalStateException("kevent failed to add user event with errno: " + (-result)); } }
void add(long value) { reallocIfNeeded(); if (PlatformDependent.hasUnsafe()) { PlatformDependent.putLong(memoryOffset(size), value); } else { memory.putLong(idx(size), value); } ++size; }
long memoryAddressEnd() { return memoryOffset(size); }
private void checkSize() { if (size == capacity) { realloc(); } }
@Override protected void cleanup() { try { try { kqueueFd.close(); } catch (IOException e) { logger.warn("Failed to close the kqueue fd.", e); } } finally { // Cleanup all native memory! // The JNI channel pointers should already be deleted because we should wait on kevent before this method, // but lets just be sure we cleanup native memory. deleteJniChannelPointers(); jniChannelPointers.free(); changeList.free(); eventList.free(); } }
KQueueEventLoop(EventLoopGroup parent, Executor executor, int maxEvents, SelectStrategy strategy, RejectedExecutionHandler rejectedExecutionHandler) { super(parent, executor, false, DEFAULT_MAX_PENDING_TASKS, rejectedExecutionHandler); selectStrategy = ObjectUtil.checkNotNull(strategy, "strategy"); this.kqueueFd = Native.newKQueue(); if (maxEvents == 0) { allowGrowing = true; maxEvents = 4096; } else { allowGrowing = false; } changeList = new KQueueEventArray(maxEvents); eventList = new KQueueEventArray(maxEvents); jniChannelPointers = new NativeLongArray(4096); int result = Native.keventAddUserEvent(kqueueFd.intValue(), KQUEUE_WAKE_UP_IDENT); if (result < 0) { cleanup(); throw new IllegalStateException("kevent failed to add user event with errno: " + (-result)); } }
private void deleteJniChannelPointers() { if (!jniChannelPointers.isEmpty()) { deleteGlobalRefs(jniChannelPointers.memoryAddress(), jniChannelPointers.memoryAddressEnd()); jniChannelPointers.clear(); } }
void add(long value) { checkSize(); PlatformDependent.putLong(memoryOffset(size++), value); }
long memoryAddressEnd() { return memoryOffset(size); }
void remove(AbstractKQueueChannel ch) throws IOException { assert inEventLoop(); if (ch.jniSelfPtr == 0) { return; } jniChannelPointers.add(ch.jniSelfPtr); ch.jniSelfPtr = 0; }
private void checkSize() { if (size == capacity) { realloc(); } }
@Override protected void cleanup() { try { try { kqueueFd.close(); } catch (IOException e) { logger.warn("Failed to close the kqueue fd.", e); } } finally { // Cleanup all native memory! // The JNI channel pointers should already be deleted because we should wait on kevent before this method, // but lets just be sure we cleanup native memory. deleteJniChannelPointers(); jniChannelPointers.free(); changeList.free(); eventList.free(); } }
KQueueEventLoop(EventLoopGroup parent, Executor executor, int maxEvents, SelectStrategy strategy, RejectedExecutionHandler rejectedExecutionHandler) { super(parent, executor, false, DEFAULT_MAX_PENDING_TASKS, rejectedExecutionHandler); selectStrategy = ObjectUtil.checkNotNull(strategy, "strategy"); this.kqueueFd = Native.newKQueue(); if (maxEvents == 0) { allowGrowing = true; maxEvents = 4096; } else { allowGrowing = false; } changeList = new KQueueEventArray(maxEvents); eventList = new KQueueEventArray(maxEvents); jniChannelPointers = new NativeLongArray(4096); int result = Native.keventAddUserEvent(kqueueFd.intValue(), KQUEUE_WAKE_UP_IDENT); if (result < 0) { cleanup(); throw new IllegalStateException("kevent failed to add user event with errno: " + (-result)); } }