Package io.javago

Class InputChannelCase<T>

java.lang.Object
io.javago.InputChannelCase<T>
Type Parameters:
T - the type of messages handled by the input channel
All Implemented Interfaces:
Runnable

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

    • InputChannelCase

      public InputChannelCase(InputChannel<T> inputChannel, Consumer<T> callback, OutputChannel<Integer> toSelector, int id, AtomicBoolean closed)
      Constructs an InputChannelCase with the specified input channel, callback, output channel, identifier, and closed state.
      Parameters:
      inputChannel - the input channel from which messages are received
      callback - the consumer to be executed when a message is received
      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 input channel case. It receives a message from the input channel and executes the callback. If the input channel is closed or the thread is interrupted, the callback is executed immediately which will close its associated Selector object if it exists. The identifier is sent to the output channel before and after executing the callback.
      Specified by:
      run in interface Runnable
      Throws:
      NoSuchElementException - if the channel is closed and empty