Cpp-Taskflow  2.0.0
tf::BasicTaskflow< E > Class Template Reference

The base class to derive a taskflow class. More...

#include <basic_taskflow.hpp>

Inheritance diagram for tf::BasicTaskflow< E >:
Collaboration diagram for tf::BasicTaskflow< E >:

Public Types

using Executor = E< Closure >
 alias of executor type
 

Public Member Functions

 BasicTaskflow ()
 constructs the taskflow with std::thread::hardware_concurrency worker threads
 
 BasicTaskflow (unsigned N)
 constructs the taskflow with N worker threads
 
 BasicTaskflow (std::shared_ptr< Executor > executor)
 constructs the taskflow with a given executor
 
 ~BasicTaskflow ()
 destructs the taskflow More...
 
std::shared_ptr< Executorshare_executor ()
 shares ownership of the executor associated with this taskflow object More...
 
std::shared_future< void > dispatch ()
 dispatches the present graph to threads and returns immediately More...
 
template<typename C >
std::shared_future< void > dispatch (C &&)
 dispatches the present graph to threads and run a callback when the graph completes More...
 
void silent_dispatch ()
 dispatches the present graph to threads and returns immediately
 
template<typename C >
void silent_dispatch (C &&callable)
 dispatches the present graph to threads and run a callback when the graph completes More...
 
void wait_for_all ()
 dispatches the present graph to threads and wait for all topologies to complete
 
void wait_for_topologies ()
 blocks until all running topologies complete and then cleans up all associated storages
 
void dump (std::ostream &ostream) const
 dumps the present task dependency graph to a std::ostream in DOT format More...
 
void dump_topologies (std::ostream &ostream) const
 dumps the present topologies to a std::ostream in DOT format More...
 
size_t num_nodes () const
 queries the number of nodes in the present task dependency graph
 
size_t num_workers () const
 queries the number of worker threads in the associated executor
 
size_t num_topologies () const
 queries the number of existing topologies
 
std::string dump () const
 dumps the present task dependency graph in DOT format to a std::string
 
std::string dump_topologies () const
 dumps the existing topologies in DOT format to a std::string
 
- Public Member Functions inherited from tf::FlowBuilder
 FlowBuilder (Graph &)
 
template<typename C >
auto emplace (C &&callable)
 creates a task from a given callable object More...
 
template<typename... C, std::enable_if_t<(sizeof...(C)> 1>
auto emplace (C &&... callables)
 creates multiple tasks from a list of callable objects at one time More...
 
template<typename C >
auto silent_emplace (C &&callable)
 creates a task from a given callable object without access to the result More...
 
template<typename... C, std::enable_if_t<(sizeof...(C)> 1>
auto silent_emplace (C &&... callables)
 creates multiple tasks from a list of callable objects without access to the results More...
 
template<typename I , typename C >
std::pair< Task, Taskparallel_for (I beg, I end, C &&callable, size_t chunk=0)
 constructs a task dependency graph of range-based parallel_for More...
 
template<typename I , typename C , std::enable_if_t< std::is_arithmetic_v< I >, void > * = nullptr>
std::pair< Task, Taskparallel_for (I beg, I end, I step, C &&callable, size_t chunk=0)
 constructs a task dependency graph of index-based parallel_for More...
 
template<typename I , typename T , typename B >
std::pair< Task, Taskreduce (I beg, I end, T &result, B &&bop)
 construct a task dependency graph of parallel reduction More...
 
template<typename I , typename T >
std::pair< Task, Taskreduce_min (I beg, I end, T &result)
 constructs a task dependency graph of parallel reduction through std::min More...
 
template<typename I , typename T >
std::pair< Task, Taskreduce_max (I beg, I end, T &result)
 constructs a task dependency graph of parallel reduction through std::max More...
 
template<typename I , typename T , typename B , typename U >
std::pair< Task, Tasktransform_reduce (I beg, I end, T &result, B &&bop, U &&uop)
 constructs a task dependency graph of parallel transformation and reduction More...
 
template<typename I , typename T , typename B , typename P , typename U >
std::pair< Task, Tasktransform_reduce (I beg, I end, T &result, B &&bop1, P &&bop2, U &&uop)
 constructs a task dependency graph of parallel transformation and reduction More...
 
Task placeholder ()
 creates an empty task More...
 
void precede (Task A, Task B)
 adds a dependency link from task A to task B More...
 
void linearize (std::vector< Task > &tasks)
 adds adjacent dependency links to a linear list of tasks More...
 
void linearize (std::initializer_list< Task > tasks)
 adds adjacent dependency links to a linear list of tasks More...
 
void broadcast (Task A, std::vector< Task > &others)
 adds dependency links from one task A to many tasks More...
 
void broadcast (Task A, std::initializer_list< Task > others)
 adds dependency links from one task A to many tasks More...
 
void gather (std::vector< Task > &others, Task A)
 adds dependency links from many tasks to one task A More...
 
void gather (std::initializer_list< Task > others, Task A)
 adds dependency links from many tasks to one task A More...
 

Detailed Description

template<template< typename... > typename E>
class tf::BasicTaskflow< E >

The base class to derive a taskflow class.

Template Parameters
Eexecutor type to use in this taskflow

This class is the base class to derive a taskflow class. It inherits all public methods to create tasks from tf::FlowBuilder and defines means to execute task dependency graphs.

Constructor & Destructor Documentation

◆ ~BasicTaskflow()

template<template< typename... > typename E>
tf::BasicTaskflow< E >::~BasicTaskflow ( )

destructs the taskflow

Destructing a taskflow object will first wait for all running topologies to finish and then clean up all associated data storages.

Member Function Documentation

◆ dispatch() [1/2]

template<template< typename... > typename E>
std::shared_future< void > tf::BasicTaskflow< E >::dispatch ( )

dispatches the present graph to threads and returns immediately

Returns
a std::shared_future to access the execution status of the dispatched graph

◆ dispatch() [2/2]

template<template< typename... > typename E>
template<typename C >
std::shared_future< void > tf::BasicTaskflow< E >::dispatch ( C &&  c)

dispatches the present graph to threads and run a callback when the graph completes

Returns
a std::shared_future to access the execution status of the dispatched graph

◆ dump()

template<template< typename... > typename E>
void tf::BasicTaskflow< E >::dump ( std::ostream ostream) const

dumps the present task dependency graph to a std::ostream in DOT format

Parameters
ostreama std::ostream target

◆ dump_topologies()

template<template< typename... > typename E>
void tf::BasicTaskflow< E >::dump_topologies ( std::ostream ostream) const

dumps the present topologies to a std::ostream in DOT format

Parameters
ostreama std::ostream target

◆ share_executor()

template<template< typename... > typename E>
std::shared_ptr< typename BasicTaskflow< E >::Executor > tf::BasicTaskflow< E >::share_executor ( )

shares ownership of the executor associated with this taskflow object

Returns
a std::shared_ptr of the executor

◆ silent_dispatch()

template<template< typename... > typename E>
template<typename C >
void tf::BasicTaskflow< E >::silent_dispatch ( C &&  callable)

dispatches the present graph to threads and run a callback when the graph completes

Parameters
callablea callable object to execute on completion

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