protected ByteBuffer allocateBuffer ( ) { if ( _buffersToReuse != null && ! _buffersToReuse . isEmpty ( ) ) { ByteBuffer bb = _buffersToReuse . poll ( ) ; bb . rewind ( ) ; bb . limit ( bb . capacity ( ) ) ; return bb ; } ByteBuffer r = StaticBuffers . getInstance ( ) . byteBuffer ( BUFFER_KEY , _bufferSize ) ; r . limit ( _bufferSize ) ; return r . order ( _order ) ; }
Allocates a new buffer or attempts to reuse an existing one .