public PoolBuffer allocate() { final PoolBuffer buffer = (isDirect || FORCE_BYTE_BUFFER_BASED_BUFFERS) ? // if isDirect || FORCE_BYTE_BUFFER - allocate ByteBufferWrapper new PoolByteBufferWrapper(isDirect ? ByteBuffer.allocateDirect(bufferSize) : ByteBuffer.allocate(bufferSize), this) : // otherwise use HeapBuffer new PoolHeapBuffer(new byte[bufferSize], this); ProbeNotifier.notifyBufferAllocated(monitoringConfig, bufferSize); return buffer; }
@Override protected ByteBufferWrapper wrapByteBuffer(final ByteBuffer buffer) { final PoolByteBufferWrapper b = new PoolByteBufferWrapper(buffer, null, // don't keep track of the owner for child buffers source, // pass the 'parent' buffer along shareCount); // pass the shareCount b.allowBufferDispose(true); shareCount.incrementAndGet(); return b; }
private void dispose0() { // check shared counter optimistically boolean isNotShared = shareCount.get() == 0; if (!isNotShared) { // try pessimistic check using CAS loop isNotShared = (shareCount.getAndDecrement() == 0); if (isNotShared) { // if the former check is true - the shared counter is negative, // so we have to reset it shareCount.set(0); } } if (isNotShared) { // we can now safely return source back to the queue source.returnToPool(); } }
private void dispose0() { // check shared counter optimistically boolean isNotShared = shareCount.get() == 0; if (!isNotShared) { // try pessimistic check using CAS loop isNotShared = (shareCount.getAndDecrement() == 0); if (isNotShared) { // if the former check is true - the shared counter is negative, // so we have to reset it shareCount.set(0); } } if (isNotShared) { // we can now safely return source back to the queue source.returnToPool(); } }
private void dispose0() { // check shared counter optimistically boolean isNotShared = shareCount.get() == 0; if (!isNotShared) { // try pessimistic check using CAS loop isNotShared = (shareCount.getAndDecrement() == 0); if (isNotShared) { // if the former check is true - the shared counter is negative, // so we have to reset it shareCount.set(0); } } if (isNotShared) { // we can now safely return source back to the queue source.returnToPool(); } }
private void dispose0() { // check shared counter optimistically boolean isNotShared = shareCount.get() == 0; if (!isNotShared) { // try pessimistic check using CAS loop isNotShared = (shareCount.getAndDecrement() == 0); if (isNotShared) { // if the former check is true - the shared counter is negative, // so we have to reset it shareCount.set(0); } } if (isNotShared) { // we can now safely return source back to the queue source.returnToPool(); } }
private void dispose0() { // check shared counter optimistically boolean isNotShared = shareCount.get() == 0; if (!isNotShared) { // try pessimistic check using CAS loop isNotShared = (shareCount.getAndDecrement() == 0); if (isNotShared) { // if the former check is true - the shared counter is negative, // so we have to reset it shareCount.set(0); } } if (isNotShared) { // we can now safely return source back to the queue source.returnToPool(); } }
private void dispose0() { // check shared counter optimistically boolean isNotShared = shareCount.get() == 0; if (!isNotShared) { // try pessimistic check using CAS loop isNotShared = (shareCount.getAndDecrement() == 0); if (isNotShared) { // if the former check is true - the shared counter is negative, // so we have to reset it shareCount.set(0); } } if (isNotShared) { // we can now safely return source back to the queue source.returnToPool(); } }
private void dispose0() { // check shared counter optimistically boolean isNotShared = shareCount.get() == 0; if (!isNotShared) { // try pessimistic check using CAS loop isNotShared = (shareCount.getAndDecrement() == 0); if (isNotShared) { // if the former check is true - the shared counter is negative, // so we have to reset it shareCount.set(0); } } if (isNotShared) { // we can now safely return source back to the queue source.returnToPool(); } }
private void dispose0() { // check shared counter optimistically boolean isNotShared = shareCount.get() == 0; if (!isNotShared) { // try pessimistic check using CAS loop isNotShared = (shareCount.getAndDecrement() == 0); if (isNotShared) { // if the former check is true - the shared counter is negative, // so we have to reset it shareCount.set(0); } } if (isNotShared) { // we can now safely return source back to the queue source.returnToPool(); } }
private void dispose0() { // check shared counter optimistically boolean isNotShared = shareCount.get() == 0; if (!isNotShared) { // try pessimistic check using CAS loop isNotShared = (shareCount.getAndDecrement() == 0); if (isNotShared) { // if the former check is true - the shared counter is negative, // so we have to reset it shareCount.set(0); } } if (isNotShared) { // we can now safely return source back to the queue source.returnToPool(); } }
private void dispose0() { // check shared counter optimistically boolean isNotShared = shareCount.get() == 0; if (!isNotShared) { // try pessimistic check using CAS loop isNotShared = (shareCount.getAndDecrement() == 0); if (isNotShared) { // if the former check is true - the shared counter is negative, // so we have to reset it shareCount.set(0); } } if (isNotShared) { // we can now safely return source back to the queue source.returnToPool(); } }
private void dispose0() { // check shared counter optimistically boolean isNotShared = shareCount.get() == 0; if (!isNotShared) { // try pessimistic check using CAS loop isNotShared = (shareCount.getAndDecrement() == 0); if (isNotShared) { // if the former check is true - the shared counter is negative, // so we have to reset it shareCount.set(0); } } if (isNotShared) { // we can now safely return source back to the queue source.returnToPool(); } }
private void dispose0() { // check shared counter optimistically boolean isNotShared = shareCount.get() == 0; if (!isNotShared) { // try pessimistic check using CAS loop isNotShared = (shareCount.getAndDecrement() == 0); if (isNotShared) { // if the former check is true - the shared counter is negative, // so we have to reset it shareCount.set(0); } } if (isNotShared) { // we can now safely return source back to the queue source.returnToPool(); } }
@Override public void dispose() { if (free) { return; } free = true; dispose0(); }
@Override public void dispose() { if (free) { return; } free = true; dispose0(); }
@Override public void dispose() { if (free) { return; } free = true; dispose0(); }
@Override protected ByteBufferWrapper wrapByteBuffer(final ByteBuffer buffer) { final PoolByteBufferWrapper b = new PoolByteBufferWrapper(buffer, null, // don't keep track of the owner for child buffers source, // pass the 'parent' buffer along shareCount); // pass the shareCount b.allowBufferDispose(true); shareCount.incrementAndGet(); return b; }
@Override protected ByteBufferWrapper wrapByteBuffer(final ByteBuffer buffer) { final PoolByteBufferWrapper b = new PoolByteBufferWrapper(buffer, null, // don't keep track of the owner for child buffers source, // pass the 'parent' buffer along shareCount); // pass the shareCount b.allowBufferDispose(true); shareCount.incrementAndGet(); return b; }
@Override protected ByteBufferWrapper wrapByteBuffer(final ByteBuffer buffer) { final PoolByteBufferWrapper b = new PoolByteBufferWrapper(buffer, null, // don't keep track of the owner for child buffers source, // pass the 'parent' buffer along shareCount); // pass the shareCount b.allowBufferDispose(true); shareCount.incrementAndGet(); return b; }