Class AsynchronousChannelStep<I,​O>

  • All Implemented Interfaces:
    de.esoco.lib.property.Fluent<CoroutineStep<I,​O>>, org.obrel.core.FluentRelatable<CoroutineStep<I,​O>>, org.obrel.core.Relatable
    Direct Known Subclasses:
    AsynchronousFileStep, AsynchronousSocketStep, ServerSocketAccept

    public abstract class AsynchronousChannelStep<I,​O>
    extends CoroutineStep<I,​O>
    The base class for coroutine steps that perform communication through instances of 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).

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static org.obrel.core.RelationType<java.nio.channels.AsynchronousChannelGroup> CHANNEL_GROUP
      State: the AsynchronousChannelGroup to associate any new asynchronous channels with.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.nio.channels.AsynchronousChannelGroup getChannelGroup​(Continuation<?> continuation)
      Returns the AsynchronousChannelGroup for asynchronous channel operations in the current scope.
      • Methods inherited from class org.obrel.core.RelatedObject

        deleteRelation, get, getRelation, getRelations, notifyRelationListeners, readRelations, relationsEqual, relationsHashCode, relationsString, set, set, transform, writeRelations
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface de.esoco.lib.property.Fluent

        _with
      • Methods inherited from interface org.obrel.core.FluentRelatable

        with, with, with
      • Methods inherited from interface org.obrel.core.Relatable

        deleteRelation, deleteRelation, deleteRelations, get, getAll, getOption, getRelation, getRelationCount, getRelations, getRelations, hasFlag, hasRelation, hasRelations, init, set, set, set, set, set, setOption, streamRelations, transform
    • Field Detail

      • CHANNEL_GROUP

        public static final org.obrel.core.RelationType<java.nio.channels.AsynchronousChannelGroup> CHANNEL_GROUP
        State: the AsynchronousChannelGroup to associate any new asynchronous channels with.
    • Constructor Detail

      • AsynchronousChannelStep

        public AsynchronousChannelStep()
    • Method Detail

      • getChannelGroup

        protected java.nio.channels.AsynchronousChannelGroup getChannelGroup​(Continuation<?> continuation)
        Returns the 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.
        Parameters:
        continuation - The channel group
        Returns:
        The channel group