public class JChunkFactory extends Object implements ChunkFactory
A chunk factory creates and manages chunks. This chunk factory manages two pools of chunks of different sizes, so that a released chunk may be reused in a different context, saving the time for allocating and collecting the associated memory. The sizes of the chunks used, and of the preallocated pools may be changed.
Modifier and Type | Field and Description |
---|---|
boolean |
verbose
Indicates whether warning message should be printed to stderr.
|
Constructor and Description |
---|
JChunkFactory()
Returns a new chunk factory
|
JChunkFactory(int big_pool_size,
int big_size,
int small_pool_size,
int small_size,
boolean verbose)
Returns a new chunk factory
|
Modifier and Type | Method and Description |
---|---|
Chunk |
newChunk()
Returns a chunk of a default (small) size.
|
Chunk |
newChunk(int size)
Returns a chunk of (at least) the specified size.
|
public boolean verbose
In particular, if verbose is true, and if all the chunks in a pool are used, a warning will be emitted. This may be useful to tune the pool sizes.
This value is defined under the name "/jonathan/JChunkFactory/verbose"
in the bootstrap context
.
public JChunkFactory()
public JChunkFactory(int big_pool_size, int big_size, int small_pool_size, int small_size, boolean verbose)
big_pool_size
- size of the big chunks poolbig_size
- size of the big chunkssmall_pool_size
- size of the small chunks poolsmall_size
- size of the small chunksverbose
- indicates whether warning messages should be printed to
stderr.verbose
public Chunk newChunk()
newChunk
in interface ChunkFactory
public Chunk newChunk(int size)
This method may return a larger chunk than expected.
newChunk
in interface ChunkFactory
size
- the expected size of the chunk.