Package com.persequor.extension.common
Class DoubleBuffer<T>
java.lang.Object
com.persequor.extension.common.DoubleBuffer<T>
- Type Parameters:
T
- type of the buffer
Implementation of the double buffer pattern. Allows splitting reading and writing operations on the continuously modified buffer.
The write operation is blocking ensuring the consistency of the current buffer whereas the read operation is only blocking for
the time of swapping the buffer. If it is important that the reading operation is not running in parallel, it must be a
responsibility of the reader to block the execution.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
DoubleBuffer
-
-
Method Details
-
write
The write operation is blocking ensuring the consistency of the current buffer.- Parameters:
writer
- writing to the buffer
-
read
The read operation is only blocking for the time of swapping the buffer.
-