# 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:
  - `Operation`

## Method Summary

Modifier and Type
Method
Description
`void`
`process(Operation task)`
This method is used to execute the provided operation without the need to specifically check for I/O events.
`void`
`process(Operation task, int require)`
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

void process(Operation task) throws IOException
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 the `SelectableChannel` 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

void process(Operation task, int require) throws IOException
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 operations `SelectableChannel` 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 events
  `require` - this is the bitmask value for interested events
Throws:
  `IOException`

### stop

void stop() throws IOException
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`