public abstract class AsynchronousChannelStep<I,O> extends CoroutineStep<I,O>
AsynchronousChannel
. It contains the inner class AsynchronousChannelStep.ChannelCallback
that implements most of the CompletionHandler
interface needed for asynchonous channel communication. The actual channel
operation must be provided to it as an implementation of the function
interface AsynchronousChannelStep.ChannelOperation
.
To simplify the generic declaration of subclasses both input and output
type are declared as ByteBuffer
, where the returned value will be the
input value. Input buffers must be provided by the preceding step in a
coroutine and initialize it for the respective channel step implemenation.
For a reading step this means that the buffer must have an adequate capacity.
For a writing step it must contain the data to write and it must have been
flipped if necessary (see Buffer.flip()
for details).
Modifier and Type | Class and Description |
---|---|
protected static class |
AsynchronousChannelStep.ChannelCallback<V,C extends java.nio.channels.AsynchronousChannel>
A
CompletionHandler implementation that performs an asynchronous
channel operation and resumes a coroutine step afterwards
(asynchronously). |
protected static interface |
AsynchronousChannelStep.ChannelOperation<C extends java.nio.channels.AsynchronousChannel>
A functional interface used as argument to
AsynchronousChannelStep.ChannelCallback . |
Modifier and Type | Field and Description |
---|---|
static org.obrel.core.RelationType<java.nio.channels.AsynchronousChannelGroup> |
CHANNEL_GROUP
State: the
AsynchronousChannelGroup to associate any new
asynchronous channels with. |
Constructor and Description |
---|
AsynchronousChannelStep() |
Modifier and Type | Method and Description |
---|---|
protected java.nio.channels.AsynchronousChannelGroup |
getChannelGroup(Continuation<?> rContinuation)
Returns the
AsynchronousChannelGroup for asynchronous channel
operations in the current scope. |
execute, fail, runAsync, runBlocking, terminateCoroutine, toString
deleteRelation, get, getRelation, getRelations, notifyRelationListeners, readRelations, relationsEqual, relationsHashCode, relationsString, set, set, transform, writeRelations
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public static final org.obrel.core.RelationType<java.nio.channels.AsynchronousChannelGroup> CHANNEL_GROUP
AsynchronousChannelGroup
to associate any new
asynchronous channels with.protected java.nio.channels.AsynchronousChannelGroup getChannelGroup(Continuation<?> rContinuation)
AsynchronousChannelGroup
for asynchronous channel
operations in the current scope. If no such group exists a new one will
be created with the ExecutorService
of the CoroutineContext
and stored as CHANNEL_GROUP
in the current
scope.rContinuation
- The channel group