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

#include <UT_TaskArena.h>

Public Member Functions

 UT_TaskArena (int max_concurrency=automatic, unsigned reserved_for_masters=1)
 
 ~UT_TaskArena ()
 
void initialize ()
 
template<typename F >
void execute (F &functor)
 
template<typename F >
void execute (const F &functor)
 

Static Public Member Functions

template<typename F >
static void enqueue (F &&f)
 
template<typename M , typename F >
static void lockedExecute (M &mutex, F &functor)
 
template<typename M , typename F >
static void lockedExecute (M &mutex, const F &functor)
 

Static Public Attributes

static const int automatic = -1
 
static SYS_AtomicInt32 theArenaCount
 

Detailed Description

Simple wrapper for running code within a tbb::task_arena. For most usages, you want to do this if you're going to spawn tasks with a lock held.

Definition at line 32 of file UT_TaskArena.h.

Constructor & Destructor Documentation

UT_TaskArena::UT_TaskArena ( int  max_concurrency = automatic,
unsigned  reserved_for_masters = 1 
)

Creates task_arena with certain concurrency limits

Sets up settings only, real construction is deferred till the first method invocation.

  • max_concurrency specifies total number of slots in arena where threads work
  • reserved_for_masters specifies number of slots to be used by master threads only. Value of 1 is default and reflects behavior of implicit arenas.
UT_TaskArena::~UT_TaskArena ( )

Member Function Documentation

template<typename F >
static void UT_TaskArena::enqueue ( F &&  f)
inlinestatic

Enqueues a task into the arena to process a functor, and immediately returns. Does not require the calling thread to join the arena.

Definition at line 95 of file UT_TaskArena.h.

template<typename F >
void UT_TaskArena::execute ( F &  functor)
inline

Joins the arena and executes a functor, then returns

If not possible to join, wraps the functor into a task, enqueues it and waits for task completion. Can decrement the arena demand for workers, causing a worker to leave and free a slot to the calling thread.

Definition at line 57 of file UT_TaskArena.h.

template<typename F >
void UT_TaskArena::execute ( const F &  functor)
inline

Joins the arena and executes a functor, then returns

If not possible to join, wraps the functor into a task, enqueues it and waits for task completion. Can decrement the arena demand for workers, causing a worker to leave and free a slot to the calling thread.

Definition at line 63 of file UT_TaskArena.h.

void UT_TaskArena::initialize ( )

Call this before using the arena if execute may be called from multiple threads.

template<typename M , typename F >
static void UT_TaskArena::lockedExecute ( M &  mutex,
F &  functor 
)
inlinestatic

Executes functor and by locking the given mutex and running it in a task_arena for exclusive work isolation.

Definition at line 74 of file UT_TaskArena.h.

template<typename M , typename F >
static void UT_TaskArena::lockedExecute ( M &  mutex,
const F &  functor 
)
inlinestatic

Executes functor and by locking the given mutex and running it in a task_arena for exclusive work isolation.

Definition at line 83 of file UT_TaskArena.h.

Member Data Documentation

const int UT_TaskArena::automatic = -1
static

Definition at line 35 of file UT_TaskArena.h.

SYS_AtomicInt32 UT_TaskArena::theArenaCount
static

Definition at line 106 of file UT_TaskArena.h.


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