public interface Cursor extends DependentOnPointers
positions
of all consumers (to keep from overlapping them), and to ensure that entries are added to the
buffer in the correct fashion using a two-phase process:
Modifier and Type | Method and Description |
---|---|
long |
claim()
Claim the next position for writing and publishing.
|
long |
claim(int number)
Claim a batch of positions for writing and publishing.
|
void |
complete()
Signal that no more entries will be written and that the
barriers will not block on this cursor and
should return a negative number from PointerBarrier.waitFor(long) . |
GarbageCollectingConsumer |
createGarbageCollectingConsumer(GarbageCollectingConsumer.Collectable collectable) |
int |
getBufferSize()
Get the size of the buffer that this cursor operates against.
|
long |
getCurrent()
Get the current position that can be read.
|
long |
getHighestPublishedPosition(long lowerPosition,
long upperPosition)
Get the highest published position that is equal to or between the supplied lower and upper positions.
|
boolean |
isComplete()
Return whether this cursor has
completed normally. |
PointerBarrier |
newBarrier()
Add a new barrier that a consumer can use the wait for the next available positions.
|
Pointer |
newPointer()
Return a new pointer that starts at this cursor's current position, ensuring that this cursor always
stays behind it on the ring buffer. |
boolean |
publish(long position)
Publish the supplied position, making it available for consumers.
|
void |
signalConsumers()
Signal that the consumers should wake up if they are blocked on the barrier.
|
ignore, stayBehind
int getBufferSize()
long getCurrent()
long claim()
long claim(int number)
number
- the number of positions to be claimed; must be greater than 0boolean publish(long position)
position
- the position that is now available for consumerslong getHighestPublishedPosition(long lowerPosition, long upperPosition)
lowerPosition
- the lowest potential positionupperPosition
- the highest potential positionPointerBarrier newBarrier()
Pointer newPointer()
stays behind
it on the ring buffer.void signalConsumers()
void complete()
barriers
will not block on this cursor and
should return a negative number from PointerBarrier.waitFor(long)
.boolean isComplete()
completed
normally.GarbageCollectingConsumer createGarbageCollectingConsumer(GarbageCollectingConsumer.Collectable collectable)
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.