HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WorkSingularTask Class Reference

#include <singularTask.h>

Public Member Functions

 WorkSingularTask (WorkSingularTask const &)=delete
 
WorkSingularTaskoperator= (WorkSingularTask const &)=delete
 
template<class Callable , class... Args>
 WorkSingularTask (WorkDispatcher &d, Callable &&c, Args &&...args)
 
void Wake ()
 

Detailed Description

A WorkSingularTask runs a task in a WorkDispatcher, but never concurrently with itself. That is, the function provided to the WorkSingularTask runs concurrently with other tasks in the WorkDispatcher, but never with another invocation of itself.

This is useful if there is single-threaded work to do that can be overlapped with other parallel tasks in a dispatcher. For example, a multiple-producer, single-consumer problem can be tackled this way. Run the producer tasks as usual in a WorkDispatcher and create a WorkSingularTask for the consumer. When a producer task has generated a result to consume, it invokes Wake() on the consumer task. This ensures that the consumer runs only when there are results to consume, and it lets the consumer operate single-threaded. For example, the consumer could populate stl containers without locking.

Definition at line 56 of file singularTask.h.

Constructor & Destructor Documentation

WorkSingularTask::WorkSingularTask ( WorkSingularTask const &  )
delete
template<class Callable , class... Args>
WorkSingularTask::WorkSingularTask ( WorkDispatcher d,
Callable &&  c,
Args &&...  args 
)
inline

Definition at line 80 of file singularTask.h.

Member Function Documentation

WorkSingularTask& WorkSingularTask::operator= ( WorkSingularTask const &  )
delete
void WorkSingularTask::Wake ( )
inline

Ensure that this task runs at least once after this call. The task is not guaranteed to run as many times as Wake() is invoked, only that it run at least once after a call to Wake().

Definition at line 90 of file singularTask.h.


The documentation for this class was generated from the following file: