T - public class RingBuffer<T> extends Object implements Destroyable, GcCleanable
| 限定符和类型 | 字段和说明 |
|---|---|
protected int |
m_EmtryCounter |
protected int |
m_FullCounter |
protected int |
m_HitCounter |
protected int |
m_IndexGet |
protected int |
m_IndexPut |
protected T[] |
m_Items |
POLICY_CRITICAL, POLICY_IDLE, POLICY_LOW, POLICY_MAINTAIN, POLICY_MASK, POLICY_OPTIMIZE| 构造器和说明 |
|---|
RingBuffer(int size) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
destroy()
执行清理
|
boolean |
empty()
清空缓冲区
|
T |
item(int index) |
boolean |
offer(T item)
置入缓冲区
|
protected void |
onDestroy(T item,
int index)
释放缓存项
|
protected T |
onEmpty()
缓冲区空了
|
protected void |
onFull(T item)
缓冲区满了
|
void |
onGcCleanup(int policy)
处理GC触发的清理事件,根据优先级以不同策略处理
|
protected void |
onInit()
初始化
|
T |
poll()
由缓冲区获取最顶的项(不置空引用),若缓冲区空则调用onEmpty返回值
|
int |
readable() |
T |
remove()
由缓冲区获取最顶的项(置空引用),若缓冲区空则调用onEmpty返回值
|
int |
size() |
String |
toString() |
int |
writable() |
protected T[] m_Items
protected volatile int m_IndexPut
protected volatile int m_IndexGet
protected volatile int m_FullCounter
protected volatile int m_EmtryCounter
protected volatile int m_HitCounter
protected void onFull(T item)
item - 要置入的项protected T onEmpty()
protected void onDestroy(T item, int index)
item - 要释放的缓存项index - 缓存项所在的位置(下标)protected void onInit()
public boolean offer(T item)
public T item(int index)
public int size()
public int readable()
public int writable()
public boolean empty()
public void destroy()
Destroyabledestroy 在接口中 Destroyablepublic void onGcCleanup(int policy)
GcCleanableonGcCleanup 在接口中 GcCleanablepolicy - POLICY_xxxCopyright © 2022. All rights reserved.