|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.undercouch.bson4jackson.io.StaticBuffers
public class StaticBuffers
Keeps thread-local re-usable buffers. Each buffer is identified by a key.
This class is a singleton, whereas the reference to the instance is hold
in a SoftReference so buffers can be freed when they are not needed
anymore.
BufferRecycler| Nested Class Summary | |
|---|---|
static class |
StaticBuffers.Key
Possible buffer keys |
| Field Summary | |
|---|---|
static int |
GLOBAL_MIN_SIZE
All buffers have a minimum size of 64 kb |
| Method Summary | |
|---|---|
java.nio.ByteBuffer |
byteBuffer(StaticBuffers.Key key,
int minSize)
|
java.nio.CharBuffer |
charBuffer(StaticBuffers.Key key,
int minSize)
Creates or re-uses a CharBuffer that has a minimum size. |
static StaticBuffers |
getInstance()
|
void |
releaseByteBuffer(StaticBuffers.Key key,
java.nio.ByteBuffer buf)
|
void |
releaseCharBuffer(StaticBuffers.Key key,
java.nio.CharBuffer buf)
Marks a buffer a being re-usable. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int GLOBAL_MIN_SIZE
| Method Detail |
|---|
public static StaticBuffers getInstance()
public java.nio.CharBuffer charBuffer(StaticBuffers.Key key,
int minSize)
CharBuffer that has a minimum size. Calling
this method multiple times with the same key will always return the
same buffer, as long as it has the minimum size and is marked to be
re-used. Buffers that are allowed to be re-used should be released using
releaseCharBuffer(Key, CharBuffer).
key - the buffer's identifierminSize - the minimum size
CharBuffer instance
public void releaseCharBuffer(StaticBuffers.Key key,
java.nio.CharBuffer buf)
key - the buffer's keybuf - the buffer
public java.nio.ByteBuffer byteBuffer(StaticBuffers.Key key,
int minSize)
charBuffer(Key, int)
public void releaseByteBuffer(StaticBuffers.Key key,
java.nio.ByteBuffer buf)
releaseCharBuffer(Key, CharBuffer)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||