libgenua
Basic Geometry, Numerical Algorithms and Interfaces
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TaskContext Class Reference

Detailed Description

Mechanism to wait for completion of a set of tasks.

Todo:
  • Investigate task object lifetime implications
See Also
TaskScheduler

#include <tasksystem.h>

Collaboration diagram for TaskContext:
[legend]

Public Member Functions

 TaskContext ()
 create a new context
 
 TaskContext (TaskScheduler &s)
 create a new context with it's own scheduler
 
template<typename F >
void enqueue (F &&f)
 enqueue a task for execution and run when resources available
 
void wait ()
 wait until all submitted tasks are completed
 

Private Member Functions

void submit (uint n=1)
 register that n more tasks will be committed to the queue
 
void completed ()
 register one task as completed
 

Private Attributes

std::atomic< uint > m_enqeued
 number of tasks in queue but not completed
 
TaskSchedulerm_scheduler = TaskScheduler::pool()
 thread pool to use
 
std::condition_variable m_completed
 notified when all tasks completed
 
std::mutex m_mutex
 mutex to protect cv
 

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