Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|Create new task group, using the calling thread's associated thread pool. |
|FXTaskGroup (FXThreadPool *p)|
|Create new task group, using the given thread pool. |
|FXThreadPool *||getThreadPool () const|
|Return threadpool. |
|FXuint||getRunningTasks () const|
|Return number of tasks. |
|FXbool||execute (FXRunnable *task)|
|Start a task in this task group. |
|FXbool||executeAndWait (FXRunnable *task)|
|Start task in this task group, and then enter the task-processing loop, returning when all tasks have been completed. More...|
|Wait until all tasks of this group have finished executing, then return. More...|
|Wait for the semaphore to be signaled, then destroy the task group. |
In a typical use, an FXTaskGroup is constructed on the stack of the calling function. If an explicit FXThreadPool is passed to the constructor of the FXTaskGroup, this is the FXThreadPool that will be used to execute the tasks. Otherwise, an instance of FXThreadPool will be located through a thread-local variable from the calling thread. This thread-local variable will be set if the calling thread is a worker thread from the FXThreadPool, or is the thread that called start() on the FXThreadPool. Tasks managed by the FXTaskGroup may be started at any time during the FXTaskGroup's lifetime. However, the FXTaskGroup can not be destroyed until the last task in the group has finished execution: the FXTaskGroup's destructor will wait until all tasks (if any) have finished executing. The calling thread can enter the task-processing loop in the FXThreadPool; it returns when either the tasks from this FXTaskGroup have been completed (count reaching zero), or when the task-queue is empty (in this case another thread may still be working on a task from the FXTaskGroup). Thus, the calling thread should block on the completion semaphore to ensure all tasks are completed.
|FXbool FX::FXTaskGroup::executeAndWait||(||FXRunnable *||task||)|
Start task in this task group, and then enter the task-processing loop, returning when all tasks have been completed.
Return false if unable to start the task.
Wait until all tasks of this group have finished executing, then return.
The completion semaphore is reset after being signaled by the last completed task.
|Copyright © 1997-2020 Jeroen van der Zijp|