public class ExecutorReactor extends Object implements Reactor
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.Constructor and Description |
---|
ExecutorReactor(Executor executor)
Constructor for the
ExecutorReactor object. |
ExecutorReactor(Executor executor,
int count)
Constructor for the
ExecutorReactor object. |
ExecutorReactor(Executor executor,
int count,
long expiry)
Constructor for the
ExecutorReactor object. |
Modifier and Type | Method and 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.
|
public ExecutorReactor(Executor executor) throws IOException
ExecutorReactor
object. 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 the SelectionKey
object. A bit mask can
be used to show interest in several operations at once.executor
- this is the executor used to run the operationsIOException
public ExecutorReactor(Executor executor, int count) throws IOException
ExecutorReactor
object. 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 the SelectionKey
object. A bit mask can
be used to show interest in several operations at once.executor
- this is the executor used to run the operationscount
- this is the number of distributors to be usedIOException
public ExecutorReactor(Executor executor, int count, long expiry) throws IOException
ExecutorReactor
object. 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 the SelectionKey
object. A bit mask can
be used to show interest in several operations at once.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 operationIOException
public void process(Operation task) throws IOException
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.process
in interface Reactor
task
- this is the task to execute immediatelyIOException
public void process(Operation task, int require) throws IOException
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.process
in interface Reactor
task
- this is the task to execute on interested eventsrequire
- this is the bit-mask value for interested eventsIOException
public void stop() throws IOException
stop
in interface Reactor
IOException
Copyright © 2022. All rights reserved.