@InterfaceAudience.Private public abstract class Chunk extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
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 |
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)
size - in bytesid - the chunk idpublic Chunk(int size,
int id,
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–2019 The Apache Software Foundation. All rights reserved.