Class CancelAction

  • All Implemented Interfaces:
    java.lang.Runnable, Action

    class CancelAction
    extends java.lang.Object
    implements Action
    The CancelAction object is used to represent a task that can be executed to cancel an operation. This is used in the place of a normal Operation to pass for execution when the operation has expired before the I/O event is was interested in occurred. Before this is executed the operation is removed from selection.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Action action
      This is the operation object that is to be canceled.
      private Operation task
      This is the operation that is to be canceled by this action.
    • Constructor Summary

      Constructors 
      Constructor Description
      CancelAction​(Action action)
      Constructor for the Cancellation object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.nio.channels.SelectableChannel getChannel()
      This is the SelectableChannel which is used to determine if the operation should be executed.
      long getExpiry()
      This is used to get the expiry for the operation.
      int getInterest()
      This returns the I/O operations that the action is interested in as an integer bit mask.
      Operation getOperation()
      This is used to acquire the Operation that is to be executed when the required operations are ready.
      void run()
      This method is executed by the Executor object if the operation expires before the required I/O event(s) have occurred.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • task

        private final Operation task
        This is the operation that is to be canceled by this action.
      • action

        private final Action action
        This is the operation object that is to be canceled.
    • Constructor Detail

      • CancelAction

        public CancelAction​(Action action)
        Constructor for the Cancellation object. This is used to create a runnable task that delegates to the cancel method of the operation. This will be executed asynchronously by the executor after being removed from selection.
        Parameters:
        action - this is the task that is to be canceled by this
    • Method Detail

      • run

        public void run()
        This method is executed by the Executor object if the operation expires before the required I/O event(s) have occurred. It is typically used to shutdown the socket and release any resources associated with the operation.
        Specified by:
        run in interface java.lang.Runnable
      • getExpiry

        public long getExpiry()
        This is used to get the expiry for the operation. The expiry represents some static time in the future when the action will expire if it does not become ready. This is used to cancel the operation so that it does not remain in the distributor.
        Specified by:
        getExpiry in interface Action
        Returns:
        the remaining time this operation will wait for
      • getInterest

        public int getInterest()
        This returns the I/O operations that the action is interested in as an integer bit mask. When any of these operations are ready the distributor will execute the provided operation.
        Specified by:
        getInterest in interface Action
        Returns:
        the integer bit mask of interested I/O operations
      • getChannel

        public java.nio.channels.SelectableChannel getChannel()
        This is the SelectableChannel which is used to determine if the operation should be executed. If the channel is ready for a given I/O event it can be run. For instance if the operation is used to perform some form of read operation it can be executed when ready to read data from the channel.
        Specified by:
        getChannel in interface Action
        Returns:
        this returns the channel used to govern execution
      • getOperation

        public Operation getOperation()
        This is used to acquire the Operation that is to be executed when the required operations are ready. It is the responsibility of the distributor to invoke the operation.
        Specified by:
        getOperation in interface Action
        Returns:
        the operation to be executed when it is ready