Package io.javago

Class OutputChannelCase<T>

java.lang.Object
io.javago.OutputChannelCase<T>
Type Parameters:
T - the type of message to be sent to the output channel
All Implemented Interfaces:
Runnable

public class OutputChannelCase<T> extends Object implements Runnable
The OutputChannelCase class is used by the Selector class to create a case that is run when a message is sent to the case's channel. It implements the Runnable interface and allows a callback to be run after the message is sent. Additionally, it sends an identifier to a specified output channel before and after executing the callback.
  • Constructor Details

    • OutputChannelCase

      public OutputChannelCase(OutputChannel<T> outputChannel, T message, Runnable callback, OutputChannel<Integer> toSelector, int id, AtomicBoolean closed)
      Constructs an OutputChannelCase with the specified output channel, message, callback, output channel for selector, identifier, and closed state.
      Parameters:
      outputChannel - the output channel to which the message will be sent
      message - the message to be sent to the output channel
      callback - the runnable to be executed after the message is sent
      toSelector - the output channel to send the identifier
      id - the identifier to be sent to the output channel
      closed - the atomic boolean indicating the closed state
  • Method Details

    • run

      public void run()
      Runs the output channel case. It sends a message to the output channel and executes the callback. If the output channel is closed or the thread is interrupted, the case returns immediately without executing the callback. This will not close its associated Selector object if it exists meaning it will still wait for a case to be completed. The identifier is sent to the output channel before and after executing the callback.
      Specified by:
      run in interface Runnable