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
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 Summary
ConstructorsConstructorDescriptionOutputChannelCase
(OutputChannel<T> outputChannel, T message, Runnable callback, OutputChannel<Integer> toSelector, int id, AtomicBoolean closed) Constructs anOutputChannelCase
with the specified output channel, message, callback, output channel for selector, identifier, and closed state. -
Method Summary
-
Constructor Details
-
OutputChannelCase
public OutputChannelCase(OutputChannel<T> outputChannel, T message, Runnable callback, OutputChannel<Integer> toSelector, int id, AtomicBoolean closed) Constructs anOutputChannelCase
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 sentmessage
- the message to be sent to the output channelcallback
- the runnable to be executed after the message is senttoSelector
- the output channel to send the identifierid
- the identifier to be sent to the output channelclosed
- 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 associatedSelector
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.
-