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

This is a specialization of the WorkDispatcher that uses an isolated arena to Run() all its tasks in. More...

Public Member Functions

 WorkArenaDispatcher ()
 Constructs a new dispatcher. More...
 
WORK_API ~WorkArenaDispatcher ()
 Wait() for any pending tasks to complete, then destroy the dispatcher. More...
 
 WorkArenaDispatcher (WorkArenaDispatcher const &)=delete
 
WorkArenaDispatcheroperator= (WorkArenaDispatcher const &)=delete
 
template<class Callable , class A1 , class A2 , ...class AN>
void Run (Callable &&c, A1 &&a1, A2 &&a2,...AN &&aN)
 Add work for the dispatcher to run. More...
 
WORK_API void Wait ()
 Block until the work started by Run() completes. More...
 
WORK_API void Cancel ()
 Cancel remaining work and return immediately. More...
 

Detailed Description

This is a specialization of the WorkDispatcher that uses an isolated arena to Run() all its tasks in.

The WorkArenaDispatcher is useful where it must be guaranteed that a specific set of tasks shall not be stolen by any other dispatcher, or where stealing from other dispatchers could cause lock dependencies that may lead to deadlocks. Note that a regular WorkDispatcher can provide better throughput, and should thus be the preferred over the WorkArenaDispatcher.

The interface of the WorkArenaDispatcher, and thread-safety notes about its API are identical to those of the WorkDispatcher.

Definition at line 55 of file arenaDispatcher.h.

Constructor & Destructor Documentation

WorkArenaDispatcher ( )
inline

Constructs a new dispatcher.

The internal arena will mirror the global concurrency limit setting.

Definition at line 60 of file arenaDispatcher.h.

WORK_API ~WorkArenaDispatcher ( )

Wait() for any pending tasks to complete, then destroy the dispatcher.

Member Function Documentation

WORK_API void Cancel ( )

Cancel remaining work and return immediately.

This call does not block. Call Wait() after Cancel() to wait for pending tasks to complete.

void Run ( Callable &&  c,
A1 &&  a1,
A2 &&  a2,
...AN &&  aN 
)

Add work for the dispatcher to run.

Before a call to Wait() is made it is safe for any client to invoke Run(). Once Wait() is invoked, it is only safe to invoke Run() from within the execution of tasks already added via Run().

This function does not block. The added work may be not yet started, may be started but not completed, or may be completed upon return. No guarantee is made.

WORK_API void Wait ( )

Block until the work started by Run() completes.


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