Package com.sodius.oslc.server.trs.store
Class BufferedConsumer<T>
java.lang.Object
com.sodius.oslc.server.trs.store.BufferedConsumer<T>
- Type Parameters:
T- the type of the input to the operation
Buffers the consumed elements so that they can be processing by chunks.
This class is useful in case performing one action on a list of elements provides better performance than an action for each element of the list.
- Since:
- 1.10.0
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBufferedConsumer(int bufferSize) Creates a consumer whose buffer with a specified maximum size. -
Method Summary
-
Constructor Details
-
BufferedConsumer
protected BufferedConsumer(int bufferSize) Creates a consumer whose buffer with a specified maximum size. Once the size of the buffer of consumed elements reaches this maximum, theflush()method is called to process the buffer.- Parameters:
bufferSize- the size of the buffer.
-
-
Method Details
-
accept
This implementation appends the element into the buffer. If the buffer of consumed elements reaches this maximum size, theflush()method is called to process the buffer. -
flush
public void flush()Callsflush(List)to process the buffer of consumed elements at once. The buffer is then reset to empty. -
flush
Performs the operation on the buffer of consumed elements.- Parameters:
buffer- the consumed elements to process.
-