Class SynchronousReactor
java.lang.Object
org.simpleframework.transport.reactor.SynchronousReactor
- All Implemented Interfaces:
Reactor
The
SynchronousReactor object is used to execute the
ready operations of within a single synchronous thread. This is
used when the I/O operations to be performed do not require much
time to execute and so will not block the execution thread.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final OperationDistributorThis is used to distribute the ready operations for execution.private final ExecutorThis is used to execute the operations that ready to run. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for theSynchronousReactorobject.SynchronousReactor(boolean cancel) Constructor for theSynchronousReactorobject. -
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.
-
Field Details
-
exchange
This is used to distribute the ready operations for execution. -
executor
This is used to execute the operations that ready to run.
-
-
Constructor Details
-
SynchronousReactor
Constructor for theSynchronousReactorobject. This is used to create a reactor that does not require thread pooling to execute the ready operations. All I/O operations are run in the selection thread and should complete quickly.- Throws:
IOException
-
SynchronousReactor
Constructor for theSynchronousReactorobject. This is used to create a reactor that does not require thread pooling to execute the ready operations. All I/O operations are run in the selection thread and should complete quickly.- Parameters:
cancel- determines the selection key should be cancelled- 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 graceful stop.- Specified by:
stopin interfaceReactor- Throws:
IOException
-