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

#include <thread.h>

Public Member Functions

 task_set (thread_pool *pool=nullptr)
 ~task_set ()
 task_set (const task_set &)=delete
const task_setoperator= (const task_set &)=delete
std::thread::id submitter () const
void push (std::future< void > &&f)
void wait_for_task (size_t taskindex, bool block=false)
void wait (bool block=false)
void check_done ()

Detailed Description

task_set is a group of future<void>'s from a thread_queue that you can add to, and when you either call wait() or just leave the task_set's scope, it will wait for all the tasks in the set to be done before proceeding.

A typical idiom for using this is:

void myfunc (int id) { ... do something ... }

thread_pool* pool (default_thread_pool()); { task_set tasks (pool); // Launch a bunch of tasks into the thread pool for (int i = 0; i < ntasks; ++i) tasks.push (pool->push (myfunc)); // The following brace, by ending the scope of 'tasks', will // wait for all those queue tasks to finish. }

Definition at line 790 of file thread.h.

Constructor & Destructor Documentation

task_set::task_set ( thread_pool pool = nullptr)

Definition at line 792 of file thread.h.

task_set::~task_set ( )

Definition at line 797 of file thread.h.

task_set::task_set ( const task_set )

Member Function Documentation

void task_set::check_done ( )

Definition at line 831 of file thread.h.

const task_set& task_set::operator= ( const task_set )
void task_set::push ( std::future< void > &&  f)

Definition at line 808 of file thread.h.

std::thread::id task_set::submitter ( ) const

Definition at line 804 of file thread.h.

void task_set::wait ( bool  block = false)
void task_set::wait_for_task ( size_t  taskindex,
bool  block = false 

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