public class RingBufferAllocator<T extends Recyclable> extends java.lang.Object implements Allocator<T>
Allocator implementation based int the LMAX Disruptor RingBuffer.| Constructor and Description |
|---|
RingBufferAllocator(java.lang.String name,
int poolSize,
Supplier<T> poolFactory) |
RingBufferAllocator(java.lang.String name,
int poolSize,
Supplier<T> poolFactory,
int eventThreads) |
RingBufferAllocator(java.lang.String name,
int poolSize,
Supplier<T> poolFactory,
int eventThreads,
com.lmax.disruptor.EventHandler<Reference<T>> eventHandler,
com.lmax.disruptor.ExceptionHandler errorHandler,
com.lmax.disruptor.dsl.ProducerType producerType,
com.lmax.disruptor.WaitStrategy waitStrategy,
java.util.concurrent.ExecutorService executor) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
alive() |
Reference<T> |
allocate()
Allocate an object from the internal pool.
|
java.util.List<Reference<T>> |
allocateBatch(int size)
Allocate a batch of objects all at once.
|
java.util.List<Reference<T>> |
allocateBatch(int size,
java.util.List<Reference<T>> refs) |
boolean |
awaitAndShutdown() |
boolean |
awaitAndShutdown(long timeout,
java.util.concurrent.TimeUnit timeUnit) |
void |
halt() |
void |
release(java.util.List<Reference<T>> batch)
Efficiently release a batch of References all at once.
|
void |
shutdown() |
void |
start() |
public RingBufferAllocator(java.lang.String name,
int poolSize,
Supplier<T> poolFactory)
public RingBufferAllocator(java.lang.String name,
int poolSize,
Supplier<T> poolFactory,
int eventThreads)
public RingBufferAllocator(java.lang.String name,
int poolSize,
Supplier<T> poolFactory,
int eventThreads,
com.lmax.disruptor.EventHandler<Reference<T>> eventHandler,
com.lmax.disruptor.ExceptionHandler errorHandler,
com.lmax.disruptor.dsl.ProducerType producerType,
com.lmax.disruptor.WaitStrategy waitStrategy,
java.util.concurrent.ExecutorService executor)
public Reference<T> allocate()
Allocatorallocate in interface Allocator<T extends Recyclable>Reference that can be retained and released.public java.util.List<Reference<T>> allocateBatch(int size, java.util.List<Reference<T>> refs)
public java.util.List<Reference<T>> allocateBatch(int size)
AllocatorallocateBatch in interface Allocator<T extends Recyclable>size - the number of objects to allocateList of References to the allocated objectspublic void release(java.util.List<Reference<T>> batch)
Allocatorrelease in interface Allocator<T extends Recyclable>batch - the references to releasepublic boolean alive()
public void start()
public boolean awaitAndShutdown()
public boolean awaitAndShutdown(long timeout,
java.util.concurrent.TimeUnit timeUnit)
public void shutdown()
public void halt()