![]() |
Taskflow
3.2.0-Master-Branch
|
class to create a critical region of limited workers to run tasks More...
#include <critical.hpp>
Public Member Functions | |
CriticalSection (size_t max_workers=1) | |
constructs a critical region of a limited number of workers | |
template<typename... Tasks> | |
void | add (Tasks...tasks) |
adds a task into the critical region | |
![]() | |
Semaphore (size_t max_workers) | |
constructs a semaphore with the given counter | |
size_t | count () const |
queries the counter value (not thread-safe during the run) | |
class to create a critical region of limited workers to run tasks
tf::CriticalSection is a warpper over tf::Semaphore and is specialized for limiting the maximum concurrency over a set of tasks. A critical section starts with an initial count representing that limit. When a task is added to the critical section, the task acquires and releases the semaphore internal to the critical section. This design avoids explicit call of tf::Task::acquire and tf::Task::release. The following example creates a critical section of one worker and adds the five tasks to the critical section.