#include <Executor.h>
Inheritance diagram for Executor:
Public Methods | |
virtual | ~Executor () throw () |
Destroy an Executor. | |
virtual void | execute (const RunnableHandle &task)=0 |
void | execute (Runnable *task) |
virtual void | cancel ()=0 |
virtual void | wait ()=0 |
virtual bool | wait (unsigned long)=0 |
Executors abstract the knowledge of how, where and when to run a task, from the task itself. They are quite versatile objects. Runnable objects can be submitted to an Executor and they will be run by the Executor at some point.
Executors do not need to be joined. They simply need to be cancel()ed at some point before the termination of your program.
An Executor implements the Cancelable interface, giving you some control over the lifetime of the Executor.
Disabling
Cancelling an Executor has the effect of preparing the Executor to shutdown, disabling it. An Executor that has been cancel()ed will no longer accept new tasks.
Disabling an Executor does not discard the tasks it has previously been assigned. Those tasks will all be executed and are not lost.
Exiting
An Executor will exit only after it has been cancel()ed. When a cancel()ed Executor depletes the tasks in its Queue, it will allow its threads to exit. If it is not cancel()ed, its threads will run indefnently, which will interfere with the clean termination of your program.
Waiting
For an Executor, waiting means waiting for the current batch of tasks to be serviced. A thread that wait()s on an Executor will be blocked until all of its enqueued tasks are being serviced.
An Executor can be wait()ed on many times. The completion of a wait() does not neccessarily mean the Executor is done running tasks and its lifetime is about to come to an end. It simply means that it is about to become idle.
|
Stop the execution of additonal tasks by this Executor. A cancel()ed Executor will complete the task that are pending, or executing, but it will not accept any new tasks.
Implements Cancelable. Implemented in ConcurrentExecutor, PoolExecutor, SynchronousExecutor, and ThreadedExecutor. |
|
Convience method
Reimplemented in ConcurrentExecutor, PoolExecutor, SynchronousExecutor, and ThreadedExecutor. |
|
Submit a light wieght task to an Executor.
Implemented in ConcurrentExecutor, PoolExecutor, SynchronousExecutor, and ThreadedExecutor. |
|
Wait for all pending and currently executing tasks to complete or or the given amount of time to expire. This method will block the calling thread, for an definite amount of time, until no more tasks are available and the Executor is about to become idle. However, this method does not garuntee that an Executor is finished executing tasks. It's possible for more tasks to be submitted after a wait()ing thread has been awakened. In order to wait() until an Executor is done running tasks for good, the Executor should first be cancel()ed.
Reimplemented from Waitable. Implemented in ConcurrentExecutor, PoolExecutor, SynchronousExecutor, and ThreadedExecutor. |
|
Wait for all pending and currently executing tasks to complete. This method will block the calling thread, for an indefinite amount of time, until no more tasks are available and the Executor is about to become idle. However, this method does not garuntee that an Executor is finished executing tasks. It's possible for more tasks to be submitted after a wait()ing thread has been awakened. In order to wait() until an Executor is done running tasks for good, the Executor should first be cancel()ed.
Reimplemented from Waitable. Implemented in ConcurrentExecutor, PoolExecutor, SynchronousExecutor, and ThreadedExecutor. |