ThreadLocal member of the owning class pointing to
instance of this class through a SoftReference. The
end result is a low-overhead GC-cleanable recycling: hopefully
ideal for use by stream readers.
Regarding implementation: the key design goal is simplicity; and to that end, different types of buffers are handled separately. While code may look inelegant as a result (would be cleaner to just have generic char[]/byte[] buffer accessors), benefit is that no data structures are needed, just simple references. As long as usage pattern is well known (which it is, for stream readers) this should be highly optimal and robust implementation.
| Modifier and Type | Field and Description |
|---|---|
| private volatile byte[] | |
| private volatile char[] | |
| private volatile char[] | |
| private volatile char[] |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized byte[] | |
| public synchronized char[] | |
| public synchronized char[] | |
| public synchronized char[] | |
| public synchronized void | |
| public synchronized void | |
| public synchronized void | |
| public synchronized void |
| mFullBBuffer | back to summary |
|---|---|
| private volatile byte[] mFullBBuffer | |
| mFullCBuffer | back to summary |
|---|---|
| private volatile char[] mFullCBuffer | |
| mMediumCBuffer | back to summary |
|---|---|
| private volatile char[] mMediumCBuffer | |
| mSmallCBuffer | back to summary |
|---|---|
| private volatile char[] mSmallCBuffer | |
| BufferRecycler | back to summary |
|---|---|
| public BufferRecycler() | |
| getFullBBuffer | back to summary |
|---|---|
| public synchronized byte[] getFullBBuffer(int minSize) | |
| getFullCBuffer | back to summary |
|---|---|
| public synchronized char[] getFullCBuffer(int minSize) | |
| getMediumCBuffer | back to summary |
|---|---|
| public synchronized char[] getMediumCBuffer(int minSize) | |
| getSmallCBuffer | back to summary |
|---|---|
| public synchronized char[] getSmallCBuffer(int minSize) | |
| returnFullBBuffer | back to summary |
|---|---|
| public synchronized void returnFullBBuffer(byte[] buffer) | |
| returnFullCBuffer | back to summary |
|---|---|
| public synchronized void returnFullCBuffer(char[] buffer) | |
| returnMediumCBuffer | back to summary |
|---|---|
| public synchronized void returnMediumCBuffer(char[] buffer) | |
| returnSmallCBuffer | back to summary |
|---|---|
| public synchronized void returnSmallCBuffer(char[] buffer) | |