HDK
|
#include <dispatcher.h>
Public Member Functions | |
WORK_API | WorkDispatcher () |
Construct a new dispatcher. More... | |
WORK_API | ~WorkDispatcher () |
Wait() for any pending tasks to complete, then destroy the dispatcher. More... | |
WorkDispatcher (WorkDispatcher const &)=delete | |
WorkDispatcher & | operator= (WorkDispatcher const &)=delete |
template<class Callable > | |
void | Run (Callable &&c) |
template<class Callable , class A0 , class... Args> | |
void | Run (Callable &&c, A0 &&a0, Args &&...args) |
WORK_API void | Wait () |
Block until the work started by Run() completes. More... | |
WORK_API void | Cancel () |
A work dispatcher runs concurrent tasks. The dispatcher supports adding new tasks from within running tasks. This suits problems that exhibit hierarchical structured parallelism: tasks that discover additional tasks during their execution.
Typical use is to create a dispatcher and invoke Run() to begin doing work, then Wait() for the work to complete. Tasks may invoke Run() during their execution as they discover additional tasks to perform.
For example,
Calls to Run() and Cancel() may be made concurrently. Calls to Wait() may also be made concurrently. However, once any calls to Wait() are in-flight, calls to Run() and Cancel() must only be made by tasks already added by Run(). This means that users of this class are responsible to synchronize concurrent calls to Wait() to ensure this requirement is met.
Additionally, Wait() must never be called by a task added by Run(), since that task could never complete.
Definition at line 75 of file dispatcher.h.
WORK_API WorkDispatcher::WorkDispatcher | ( | ) |
Construct a new dispatcher.
WORK_API WorkDispatcher::~WorkDispatcher | ( | ) |
Wait() for any pending tasks to complete, then destroy the dispatcher.
|
delete |
Cancel remaining work and return immediately.
Calling this function affects task that are being run directly by this dispatcher. If any of these tasks are using their own dispatchers to run tasks, these dispatchers will not be affected and these tasks will run to completion, unless they are also explicitly cancelled.
This call does not block. Call Wait() after Cancel() to wait for pending tasks to complete.
|
delete |
|
inline |
Definition at line 105 of file dispatcher.h.
|
inline |
Definition at line 110 of file dispatcher.h.