Interface Reactor
- All Known Implementing Classes:
DirectReactor
,ExecutorReactor
public interface Reactor
The
Reactor
interface is used to describe an object
that is used to schedule asynchronous I/O operations. An operation
is performed by handing it to the reactor, which will determine
if an interested event has occurred. This allows the operation to
perform the task in a manner that does not block.
Implementing an Operation
object requires that the
operation itself is aware of the I/O task it is performing. For
example, if the operation is concerned with reading data from the
underlying channel then the operation should perform the read, if
there is more data required then that operation to register with
the reactor again to receive further notifications.
- Author:
- Niall Gallagher
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This method is used to execute the provided operation without the need to specifically check for I/O events.void
This method is used to execute the provided operation when there is an I/O event that task is interested in.void
stop()
This is used to stop the reactor so that further requests to execute operations does nothing.
-
Method Details
-
process
This method is used to execute the provided operation without the need to specifically check for I/O events. This is used if the operation knows that theSelectableChannel
is ready, or if the I/O operation can be performed without knowing if the channel is ready. Typically this is an efficient means to perform a poll rather than a select on the channel.- Parameters:
task
- this is the task to execute immediately- Throws:
IOException
-
process
This method is used to execute the provided operation when there is an I/O event that task is interested in. This will used the operationsSelectableChannel
object to determine the events that are ready on the channel. If this reactor is interested in any of the ready events then the task is executed.- Parameters:
task
- this is the task to execute on interested eventsrequire
- this is the bitmask value for interested events- Throws:
IOException
-
stop
This is used to stop the reactor so that further requests to execute operations does nothing. This will clean up all of the reactors resources and unregister any operations that are currently awaiting execution. This should be used to ensure any threads used by the reactor gracefully stop.- Throws:
IOException
-