Tabnine Logo
PooledMemoryManager$PoolHeapBuffer
Code IndexAdd Tabnine to your IDE (free)

How to use
PooledMemoryManager$PoolHeapBuffer
in
org.glassfish.grizzly.memory

Best Java code snippets using org.glassfish.grizzly.memory.PooledMemoryManager$PoolHeapBuffer (Showing top 20 results out of 315)

origin: org.glassfish.grizzly/grizzly-http-server-core

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;
}
origin: javaee/grizzly

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();
  }
}
origin: javaee/grizzly

private HeapBuffer asReadOnlyBuffer(final int offset, final int cap) {
  checkDispose();
  onShareHeap();
  final HeapBuffer b = new ReadOnlyHeapBuffer(heap, offset, cap) {
    @Override
    public void dispose() {
      super.dispose();
      PoolHeapBuffer.this.dispose0();
    }
    
    @Override
    protected void onShareHeap() {
      PoolHeapBuffer.this.onShareHeap();
    }
    @Override
    protected HeapBuffer createHeapBuffer(final int offset,
        final int capacity) {
      return PoolHeapBuffer.this.asReadOnlyBuffer(offset, capacity);
    }
  };
  
  b.allowBufferDispose(true);
  
  return b;            
}

origin: javaee/grizzly

private HeapBuffer asReadOnlyBuffer(final int offset, final int cap) {
  checkDispose();
  onShareHeap();
  final HeapBuffer b = new ReadOnlyHeapBuffer(heap, offset, cap) {
    @Override
    public void dispose() {
      super.dispose();
      PoolHeapBuffer.this.dispose0();
    }
    
    @Override
    protected void onShareHeap() {
      PoolHeapBuffer.this.onShareHeap();
    }
    @Override
    protected HeapBuffer createHeapBuffer(final int offset,
        final int capacity) {
      return PoolHeapBuffer.this.asReadOnlyBuffer(offset, capacity);
    }
  };
  
  b.allowBufferDispose(true);
  
  return b;            
}

origin: javaee/grizzly

private HeapBuffer asReadOnlyBuffer(final int offset, final int cap) {
  checkDispose();
  onShareHeap();
  final HeapBuffer b = new ReadOnlyHeapBuffer(heap, offset, cap) {
    @Override
    public void dispose() {
      super.dispose();
      PoolHeapBuffer.this.dispose0();
    }
    
    @Override
    protected void onShareHeap() {
      PoolHeapBuffer.this.onShareHeap();
    }
    @Override
    protected HeapBuffer createHeapBuffer(final int offset,
        final int capacity) {
      return PoolHeapBuffer.this.asReadOnlyBuffer(offset, capacity);
    }
  };
  
  b.allowBufferDispose(true);
  
  return b;            
}

origin: org.glassfish.grizzly/grizzly-http-server-core

private HeapBuffer asReadOnlyBuffer(final int offset, final int cap) {
  checkDispose();
  onShareHeap();
  final HeapBuffer b = new ReadOnlyHeapBuffer(heap, offset, cap) {
    @Override
    public void dispose() {
      super.dispose();
      PoolHeapBuffer.this.dispose0();
    }
    
    @Override
    protected void onShareHeap() {
      PoolHeapBuffer.this.onShareHeap();
    }
    @Override
    protected HeapBuffer createHeapBuffer(final int offset,
        final int capacity) {
      return PoolHeapBuffer.this.asReadOnlyBuffer(offset, capacity);
    }
  };
  
  b.allowBufferDispose(true);
  
  return b;            
}

origin: javaee/grizzly

private HeapBuffer asReadOnlyBuffer(final int offset, final int cap) {
  checkDispose();
  onShareHeap();
  final HeapBuffer b = new ReadOnlyHeapBuffer(heap, offset, cap) {
    @Override
    public void dispose() {
      super.dispose();
      PoolHeapBuffer.this.dispose0();
    }
    
    @Override
    protected void onShareHeap() {
      PoolHeapBuffer.this.onShareHeap();
    }
    @Override
    protected HeapBuffer createHeapBuffer(final int offset,
        final int capacity) {
      return PoolHeapBuffer.this.asReadOnlyBuffer(offset, capacity);
    }
  };
  
  b.allowBufferDispose(true);
  
  return b;            
}

origin: javaee/grizzly

private HeapBuffer asReadOnlyBuffer(final int offset, final int cap) {
  checkDispose();
  onShareHeap();
  final HeapBuffer b = new ReadOnlyHeapBuffer(heap, offset, cap) {
    @Override
    public void dispose() {
      super.dispose();
      PoolHeapBuffer.this.dispose0();
    }
    
    @Override
    protected void onShareHeap() {
      PoolHeapBuffer.this.onShareHeap();
    }
    @Override
    protected HeapBuffer createHeapBuffer(final int offset,
        final int capacity) {
      return PoolHeapBuffer.this.asReadOnlyBuffer(offset, capacity);
    }
  };
  
  b.allowBufferDispose(true);
  
  return b;            
}

origin: org.mule.glassfish.grizzly/grizzly-framework

private HeapBuffer asReadOnlyBuffer(final int offset, final int cap) {
  checkDispose();
  onShareHeap();
  final HeapBuffer b = new ReadOnlyHeapBuffer(heap, offset, cap) {
    @Override
    public void dispose() {
      super.dispose();
      PoolHeapBuffer.this.dispose0();
    }
    
    @Override
    protected void onShareHeap() {
      PoolHeapBuffer.this.onShareHeap();
    }
    @Override
    protected HeapBuffer createHeapBuffer(final int offset,
        final int capacity) {
      return PoolHeapBuffer.this.asReadOnlyBuffer(offset, capacity);
    }
  };
  
  b.allowBufferDispose(true);
  
  return b;            
}

origin: org.glassfish.grizzly/grizzly-core

private HeapBuffer asReadOnlyBuffer(final int offset, final int cap) {
  checkDispose();
  onShareHeap();
  final HeapBuffer b = new ReadOnlyHeapBuffer(heap, offset, cap) {
    @Override
    public void dispose() {
      super.dispose();
      PoolHeapBuffer.this.dispose0();
    }
    
    @Override
    protected void onShareHeap() {
      PoolHeapBuffer.this.onShareHeap();
    }
    @Override
    protected HeapBuffer createHeapBuffer(final int offset,
        final int capacity) {
      return PoolHeapBuffer.this.asReadOnlyBuffer(offset, capacity);
    }
  };
  
  b.allowBufferDispose(true);
  
  return b;            
}

origin: javaee/grizzly

private HeapBuffer asReadOnlyBuffer(final int offset, final int cap) {
  checkDispose();
  onShareHeap();
  final HeapBuffer b = new ReadOnlyHeapBuffer(heap, offset, cap) {
    @Override
    public void dispose() {
      super.dispose();
      PoolHeapBuffer.this.dispose0();
    }
    
    @Override
    protected void onShareHeap() {
      PoolHeapBuffer.this.onShareHeap();
    }
    @Override
    protected HeapBuffer createHeapBuffer(final int offset,
        final int capacity) {
      return PoolHeapBuffer.this.asReadOnlyBuffer(offset, capacity);
    }
  };
  
  b.allowBufferDispose(true);
  
  return b;            
}

origin: javaee/grizzly

private HeapBuffer asReadOnlyBuffer(final int offset, final int cap) {
  checkDispose();
  onShareHeap();
  final HeapBuffer b = new ReadOnlyHeapBuffer(heap, offset, cap) {
    @Override
    public void dispose() {
      super.dispose();
      PoolHeapBuffer.this.dispose0();
    }
    
    @Override
    protected void onShareHeap() {
      PoolHeapBuffer.this.onShareHeap();
    }
    @Override
    protected HeapBuffer createHeapBuffer(final int offset,
        final int capacity) {
      return PoolHeapBuffer.this.asReadOnlyBuffer(offset, capacity);
    }
  };
  
  b.allowBufferDispose(true);
  
  return b;            
}

origin: javaee/grizzly

private HeapBuffer asReadOnlyBuffer(final int offset, final int cap) {
  checkDispose();
  onShareHeap();
  final HeapBuffer b = new ReadOnlyHeapBuffer(heap, offset, cap) {
    @Override
    public void dispose() {
      super.dispose();
      PoolHeapBuffer.this.dispose0();
    }
    
    @Override
    protected void onShareHeap() {
      PoolHeapBuffer.this.onShareHeap();
    }
    @Override
    protected HeapBuffer createHeapBuffer(final int offset,
        final int capacity) {
      return PoolHeapBuffer.this.asReadOnlyBuffer(offset, capacity);
    }
  };
  
  b.allowBufferDispose(true);
  
  return b;            
}

origin: org.glassfish.grizzly/grizzly-websockets-server

private HeapBuffer asReadOnlyBuffer(final int offset, final int cap) {
  checkDispose();
  onShareHeap();
  final HeapBuffer b = new ReadOnlyHeapBuffer(heap, offset, cap) {
    @Override
    public void dispose() {
      super.dispose();
      PoolHeapBuffer.this.dispose0();
    }
    
    @Override
    protected void onShareHeap() {
      PoolHeapBuffer.this.onShareHeap();
    }
    @Override
    protected HeapBuffer createHeapBuffer(final int offset,
        final int capacity) {
      return PoolHeapBuffer.this.asReadOnlyBuffer(offset, capacity);
    }
  };
  
  b.allowBufferDispose(true);
  
  return b;            
}

origin: org.glassfish.grizzly/grizzly-http-server-core

/**
 * Create a new {@link HeapBuffer} based on the current heap.
 * 
 * @param offs relative offset, the absolute value will calculated as (this.offset + offs)
 * @param capacity the capacity of this {@link HeapBuffer}.
 *
 * @return a new {@link HeapBuffer} based on the the method arguments.
 */
@Override
protected HeapBuffer createHeapBuffer(final int offs, final int capacity) {
  onShareHeap();
  final PoolHeapBuffer b =
      new PoolHeapBuffer(heap, offs + offset, capacity,
          null, // don't keep track of the owner for child buffers
          source, // pass the 'parent' buffer along
          shareCount); // pass the shareCount
  b.allowBufferDispose(true);
  return b;
}
origin: org.glassfish.grizzly/grizzly-websockets-server

/**
 * Create a new {@link HeapBuffer} based on the current heap.
 * 
 * @param offs relative offset, the absolute value will calculated as (this.offset + offs)
 * @param capacity the capacity of this {@link HeapBuffer}.
 *
 * @return a new {@link HeapBuffer} based on the the method arguments.
 */
@Override
protected HeapBuffer createHeapBuffer(final int offs, final int capacity) {
  onShareHeap();
  final PoolHeapBuffer b =
      new PoolHeapBuffer(heap, offs + offset, capacity,
          null, // don't keep track of the owner for child buffers
          source, // pass the 'parent' buffer along
          shareCount); // pass the shareCount
  b.allowBufferDispose(true);
  return b;
}
origin: org.mule.glassfish.grizzly/grizzly-framework

/**
 * Create a new {@link HeapBuffer} based on the current heap.
 * 
 * @param offs relative offset, the absolute value will calculated as (this.offset + offs)
 * @param capacity the capacity of this {@link HeapBuffer}.
 *
 * @return a new {@link HeapBuffer} based on the the method arguments.
 */
@Override
protected HeapBuffer createHeapBuffer(final int offs, final int capacity) {
  onShareHeap();
  final PoolHeapBuffer b =
      new PoolHeapBuffer(heap, offs + offset, capacity,
          null, // don't keep track of the owner for child buffers
          source, // pass the 'parent' buffer along
          shareCount); // pass the shareCount
  b.allowBufferDispose(true);
  return b;
}
origin: javaee/grizzly

/**
 * Create a new {@link HeapBuffer} based on the current heap.
 * 
 * @param offs relative offset, the absolute value will calculated as (this.offset + offs)
 * @param capacity the capacity of this {@link HeapBuffer}.
 *
 * @return a new {@link HeapBuffer} based on the the method arguments.
 */
@Override
protected HeapBuffer createHeapBuffer(final int offs, final int capacity) {
  onShareHeap();
  final PoolHeapBuffer b =
      new PoolHeapBuffer(heap, offs + offset, capacity,
          null, // don't keep track of the owner for child buffers
          source, // pass the 'parent' buffer along
          shareCount); // pass the shareCount
  b.allowBufferDispose(true);
  return b;
}
origin: javaee/grizzly

/**
 * Create a new {@link HeapBuffer} based on the current heap.
 * 
 * @param offs relative offset, the absolute value will calculated as (this.offset + offs)
 * @param capacity the capacity of this {@link HeapBuffer}.
 *
 * @return a new {@link HeapBuffer} based on the the method arguments.
 */
@Override
protected HeapBuffer createHeapBuffer(final int offs, final int capacity) {
  onShareHeap();
  final PoolHeapBuffer b =
      new PoolHeapBuffer(heap, offs + offset, capacity,
          null, // don't keep track of the owner for child buffers
          source, // pass the 'parent' buffer along
          shareCount); // pass the shareCount
  b.allowBufferDispose(true);
  return b;
}
origin: javaee/grizzly

/**
 * Create a new {@link HeapBuffer} based on the current heap.
 * 
 * @param offs relative offset, the absolute value will calculated as (this.offset + offs)
 * @param capacity the capacity of this {@link HeapBuffer}.
 *
 * @return a new {@link HeapBuffer} based on the the method arguments.
 */
@Override
protected HeapBuffer createHeapBuffer(final int offs, final int capacity) {
  onShareHeap();
  final PoolHeapBuffer b =
      new PoolHeapBuffer(heap, offs + offset, capacity,
          null, // don't keep track of the owner for child buffers
          source, // pass the 'parent' buffer along
          shareCount); // pass the shareCount
  b.allowBufferDispose(true);
  return b;
}
org.glassfish.grizzly.memoryPooledMemoryManager$PoolHeapBuffer

Most used methods

  • <init>
  • allowBufferDispose
  • asReadOnlyBuffer
  • checkDispose
    Override the default implementation to check the free status of this buffer (i.e., once released, op
  • clear
  • dispose0
  • onShareHeap
  • returnToPool

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSharedPreferences (Context)
  • compareTo (BigDecimal)
  • findViewById (Activity)
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now