Class ConcurrentRingBuffer<T>
java.lang.Object
uno.xifan.id.generator.distributed.segmentid.concurrent.ConcurrentRingBuffer<T>
-
Constructor Summary
ConstructorsConstructorDescriptionConcurrentRingBuffer(int capacity, boolean overwrite) 创建环形缓冲区(默认非公平锁)ConcurrentRingBuffer(int capacity, boolean overwrite, boolean fair) 创建环形缓冲区 -
Method Summary
-
Constructor Details
-
ConcurrentRingBuffer
public ConcurrentRingBuffer(int capacity, boolean overwrite, boolean fair) 创建环形缓冲区- Parameters:
capacity- 缓冲区容量overwrite- 当缓冲区满时,是否覆盖最旧数据fair- 是否使用公平锁
-
ConcurrentRingBuffer
public ConcurrentRingBuffer(int capacity, boolean overwrite) 创建环形缓冲区(默认非公平锁)- Parameters:
capacity- 缓冲区容量overwrite- 当缓冲区满时,是否覆盖最旧数据
-
-
Method Details
-
put
- Throws:
InterruptedException
-
put
- Throws:
InterruptedException
-
offer
-
take
- Throws:
InterruptedException
-
poll
- Throws:
InterruptedException
-
poll
-
size
public int size() -
capacity
public int capacity() -
isEmpty
public boolean isEmpty() -
isFull
public boolean isFull() -
clear
public void clear()
-