@InterfaceAudience.Private public abstract class Chunk extends Object
| Modifier and Type | Field and Description |
|---|---|
protected AtomicInteger |
allocCount
Total number of allocations satisfied from this buffer
|
protected ByteBuffer |
data
Actual underlying data
|
protected AtomicInteger |
nextFreeOffset
Offset for the next allocation, or the sentinel value -1 which implies that the chunk is still
uninitialized.
|
protected static int |
OOM |
protected int |
size
Size of chunk in bytes
|
protected static int |
UNINITIALIZED |
| Constructor and Description |
|---|
Chunk(int size,
int id,
ChunkCreator.ChunkType chunkType)
Create an uninitialized chunk.
|
Chunk(int size,
int id,
ChunkCreator.ChunkType chunkType,
boolean fromPool)
Create an uninitialized chunk.
|
| Modifier and Type | Method and Description |
|---|---|
int |
alloc(int size)
Try to allocate
size bytes from the chunk. |
void |
init()
Actually claim the memory for this chunk.
|
String |
toString() |
protected ByteBuffer data
protected static final int UNINITIALIZED
protected static final int OOM
protected AtomicInteger nextFreeOffset
protected AtomicInteger allocCount
protected final int size
public Chunk(int size,
int id,
ChunkCreator.ChunkType chunkType)
size - in bytesid - the chunk idpublic Chunk(int size,
int id,
ChunkCreator.ChunkType chunkType,
boolean fromPool)
size - in bytesid - the chunk idfromPool - if the chunk is formed by poolpublic void init()
public int alloc(int size)
size bytes from the chunk. If a chunk is tried to get allocated
before init() call, the thread doing the allocation will be in busy-wait state as it will keep
looping till the nextFreeOffset is set.Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.