Class ExecutorReactor
java.lang.Object
org.simpleframework.transport.reactor.ExecutorReactor
- All Implemented Interfaces:
Reactor
The
ExecutorReactor is used to schedule operation for
execution using an Executor implementation. This can be
useful when the operations performed are time intensive. For example
if the operations performed a read of the underlying channel and
then had to parse the contents of the payload. Such operations would
reduce the performance of the reactor if it could not delegate to
some other form of executor, as it would delay their execution.- Author:
- Niall Gallagher
-
Constructor Summary
ConstructorsConstructorDescriptionExecutorReactor(Executor executor) Constructor for theExecutorReactorobject.ExecutorReactor(Executor executor, int count) Constructor for theExecutorReactorobject.ExecutorReactor(Executor executor, int count, long expiry) Constructor for theExecutorReactorobject. -
Method Summary
Modifier and TypeMethodDescriptionvoidThis method is used to execute the provided operation without the need to specifically check for I/O events.voidThis method is used to execute the provided operation when there is an I/O event that task is interested in.voidstop()This is used to stop the reactor so that further requests to execute operations does nothing.
-
Constructor Details
-
ExecutorReactor
Constructor for theExecutorReactorobject. This is used to create a reactor that can delegate to the executor. This also accepts the operations it is interested in, the value is taken from theSelectionKeyobject. A bit mask can be used to show interest in several operations at once.- Parameters:
executor- this is the executor used to run the operations- Throws:
IOException
-
ExecutorReactor
Constructor for theExecutorReactorobject. This is used to create a reactor that can delegate to the executor. This also accepts the operations it is interested in, the value is taken from theSelectionKeyobject. A bit mask can be used to show interest in several operations at once.- Parameters:
executor- this is the executor used to run the operationscount- this is the number of distributors to be used- Throws:
IOException
-
ExecutorReactor
Constructor for theExecutorReactorobject. This is used to create a reactor that can delegate to the executor. This also accepts the operations it is interested in, the value is taken from theSelectionKeyobject. A bit mask can be used to show interest in several operations at once.- Parameters:
executor- this is the executor used to run the operationscount- this is the number of distributors to be usedexpiry- the length of time to maintain and idle operation- Throws:
IOException
-
-
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 theSelectableChannelis 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.- Specified by:
processin interfaceReactor- 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 operationsSelectableChannelobject 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.- Specified by:
processin interfaceReactor- Parameters:
task- this is the task to execute on interested eventsrequire- this is the bit-mask 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.- Specified by:
stopin interfaceReactor- Throws:
IOException
-