Package org.jgrapes.io.events
Class IOEvent<T extends Buffer>
- Type Parameters:
T
- the type of data used in this event
- All Implemented Interfaces:
Future<Void>
,Associator
,Eligible
Events of this type signal that a new chunk of data is available
for processing.
From a consumer’s point of view, the data is
kept in a NIO Buffer
. However, when creating the event
the data has to be provided as a ManagedBuffer
.
This buffer is returned to the pool upon successful processing
of the event.
As a convenience, the class provides the methods known
from Buffer
as short-cuts for invoking
data().
method().
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State
-
Field Summary
Fields inherited from class org.jgrapes.core.internal.EventBase
completed, completionEvents, invokedFor
-
Constructor Summary
ModifierConstructorDescriptionprotected
IOEvent
(ManagedBuffer<T> buffer, boolean endOfRecord) Instantiates a new IO event. -
Method Summary
Modifier and TypeMethodDescriptionbuffer()
Get the managed buffer with the data from this event.data()
Return the data associated with this event asBuffer
.protected void
handled()
Invoked after all handlers for the event have been executed.final boolean
boolean
Return the end of record flag passed to the constructor.final int
toString()
Methods inherited from class org.jgrapes.core.Event
addCompletionEvent, associated, cancel, channels, channels, completionEvents, currentResults, defaultCriterion, forChannels, get, get, handlingError, isCancelled, isDone, isEligibleFor, isStopped, processedBy, results, results, resumeHandling, setAssociated, setChannels, setRequiresResult, setResult, stop, suspendHandling, suspendHandling, tieTo
Methods inherited from class org.jgrapes.core.internal.EventBase
disableTracking, enqueued, firstResultAssigned, isTracked, onCompletion
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jgrapes.core.Associator
associated, associated, associated, associatedGet
Methods inherited from interface java.util.concurrent.Future
exceptionNow, resultNow, state
-
Constructor Details
-
IOEvent
Instantiates a new IO event.- Parameters:
buffer
- the bufferendOfRecord
- the end of record
-
-
Method Details
-
buffer
Get the managed buffer with the data from this event.- Returns:
- the buffer
-
data
Return the data associated with this event asBuffer
.This is short for
buffer().backingBuffer()
.- Returns:
- the data
-
isEndOfRecord
Return the end of record flag passed to the constructor.The precise interpretation of a record depends on the data handled.
- Returns:
- the end of record flag
-
handled
Description copied from class:Event
Invoked after all handlers for the event have been executed.May be overridden by derived classes to cause some immediate effect (instead of e.g. waiting for the completion event). The default implementation does nothing. This method is invoked by the event handler thread and must not block.
-
toString
-
hasRemaining
- Returns:
- the result
- See Also:
-
remaining
- Returns:
- the result
- See Also:
-