Electroneum
Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
tools::task_region_handle Class Reference

#include <task_region.h>

Collaboration diagram for tools::task_region_handle:
Collaboration graph
[legend]

Classes

struct  state
 
struct  wrapper
 

Public Member Functions

 task_region_handle ()=delete
 
 task_region_handle (const task_region_handle &)=delete
 
 task_region_handle (task_region_handle &&)=delete
 
 ~task_region_handle () noexcept
 Cancels unstarted pending tasks, and waits for them to respond. More...
 
task_region_handleoperator= (const task_region_handle &)=delete
 
task_region_handleoperator= (task_region_handle &&)=delete
 
template<typename F >
void run (F &&f)
 
void wait () noexcept
 Wait until all functions provided to run have completed. More...
 

Private Member Functions

 task_region_handle (thread_group &threads_src)
 
void create_state ()
 
void do_wait () noexcept
 

Private Attributes

std::shared_ptr< statest
 
thread_groupthreads
 
state::id next_id
 

Friends

struct task_region_
 

Detailed Description

A model of the fork-join concept. run(...) "forks" (i.e. spawns new tasks), and ~task_region_handle() or wait() "joins" the spawned tasks. wait will block until all tasks have completed, while ~task_region_handle() blocks until all tasks have completed or aborted.

Do NOT give this object to separate thread of execution (which includes task_region_handle::run(...)) because joining on a different thread is undesireable (potential deadlock).

This class cannot be constructed directly, use the function task_region(...) instead.

Constructor & Destructor Documentation

◆ task_region_handle() [1/4]

tools::task_region_handle::task_region_handle ( )
delete

◆ task_region_handle() [2/4]

tools::task_region_handle::task_region_handle ( const task_region_handle )
delete

◆ task_region_handle() [3/4]

tools::task_region_handle::task_region_handle ( task_region_handle &&  )
delete

◆ ~task_region_handle()

tools::task_region_handle::~task_region_handle ( )
inlinenoexcept

Cancels unstarted pending tasks, and waits for them to respond.

◆ task_region_handle() [4/4]

tools::task_region_handle::task_region_handle ( thread_group threads_src)
inlineexplicitprivate

Member Function Documentation

◆ create_state()

void tools::task_region_handle::create_state ( )
private

◆ do_wait()

void tools::task_region_handle::do_wait ( )
privatenoexcept

◆ operator=() [1/2]

task_region_handle& tools::task_region_handle::operator= ( const task_region_handle )
delete

◆ operator=() [2/2]

task_region_handle& tools::task_region_handle::operator= ( task_region_handle &&  )
delete

◆ run()

template<typename F >
void tools::task_region_handle::run ( F &&  f)
inline

If the group has no threads, f is immediately run before returning. Otherwise, f is dispatched to the thread_group associated with this region. If f is dispatched to another thread, and it throws, the process will immediately terminate. See std::packaged_task for getting exceptions on functions executed on other threads.

◆ wait()

void tools::task_region_handle::wait ( )
inlinenoexcept

Wait until all functions provided to run have completed.

Friends And Related Function Documentation

◆ task_region_

friend struct task_region_
friend

Member Data Documentation

◆ next_id

state::id tools::task_region_handle::next_id
private

◆ st

std::shared_ptr<state> tools::task_region_handle::st
private

◆ threads

thread_group& tools::task_region_handle::threads
private

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