transwarp
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
transwarp Namespace Reference

The transwarp namespace. More...

Namespaces

 detail
 Detail namespace for internal functionality only.
 

Classes

struct  accept_any_type
 The accept_any type. Used for tag dispatch. More...
 
struct  accept_type
 The accept type. Used for tag dispatch. More...
 
struct  consume_any_type
 The consume_any type. Used for tag dispatch. More...
 
struct  consume_type
 The consume type. Used for tag dispatch. More...
 
class  control_error
 Exception thrown when a task is used in unintended ways. More...
 
struct  decay
 Removes reference and const from a type. More...
 
class  edge
 An edge between two tasks. More...
 
class  executor
 The executor interface used to perform custom task execution. More...
 
class  functor
 A base class for a user-defined functor that needs access to the associated task or a cancel point to stop a task while it's running. More...
 
class  invalid_parameter
 Exception thrown when an invalid parameter was passed to a function. More...
 
class  itask
 An interface for the task class. More...
 
class  listener
 The listener interface to listen to events raised by tasks. More...
 
struct  no_op_functor
 A functor not doing nothing. More...
 
class  parallel
 Executor for parallel execution. Uses a simple thread pool. More...
 
class  releaser
 The releaser will release a task's future when the task's after_satisfied event was received which happens when all children received the task's result. The releaser should be used in cases where the task's result is only needed for consumption by its children and can then be discarded. More...
 
struct  result
 Returns the result type of a std::shared_future<T> More...
 
struct  root_type
 The root type. Used for tag dispatch. More...
 
class  sequential
 Executor for sequential execution. Runs functors sequentially on the same thread. More...
 
class  task
 The task class. More...
 
class  task< ResultType & >
 The task class (reference result type) More...
 
class  task< void >
 The task class (void result type) More...
 
class  task_canceled
 Exception thrown when a task is canceled. More...
 
class  task_destroyed
 Exception thrown when a task was destroyed prematurely. More...
 
class  task_impl
 A task representing a piece of work given by functor and parent tasks. By connecting tasks a directed acyclic graph is built. Tasks should be created using the make_task factory functions. More...
 
class  task_pool
 A task pool that allows running multiple instances of the same task in parallel. More...
 
class  timer
 A timer that tracks the average idle, wait, and run time of each task it listens to. More...
 
class  transwarp_error
 Base class for exceptions. More...
 
class  value_task
 A value task that stores a single value and doesn't require scheduling. Value tasks should be created using the make_value_task factory functions. More...
 
struct  wait_any_type
 The wait_any type. Used for tag dispatch. More...
 
struct  wait_type
 The wait type. Used for tag dispatch. More...
 

Typedefs

using any_data = std::any
 
using option_str = std::optional< std::string >
 
using str_view = std::string_view
 

Enumerations

enum  task_type {
  task_type::root, task_type::accept, task_type::accept_any, task_type::consume,
  task_type::consume_any, task_type::wait, task_type::wait_any
}
 The possible task types. More...
 
enum  event_type {
  event_type::before_scheduled, event_type::after_future_changed, event_type::before_started, event_type::before_invoked,
  event_type::after_finished, event_type::after_canceled, event_type::after_satisfied, event_type::after_custom_data_set,
  count
}
 The task events that can be subscribed to using the listener interface. More...
 

Functions

std::string to_string (const transwarp::task_type &type)
 String conversion for the task_type enumeration.
 
std::string to_string (const transwarp::itask &task, transwarp::str_view separator="\n")
 String conversion for the itask class.
 
std::string to_string (const transwarp::edge &edge, transwarp::str_view separator="\n")
 String conversion for the edge class.
 
std::string to_string (const std::vector< transwarp::edge > &edges, transwarp::str_view separator="\n")
 Creates a dot-style string from the given edges.
 
template<typename TaskType , typename Functor , typename... Parents>
auto make_task (TaskType, Functor &&functor, std::shared_ptr< Parents >... parents) -> std::shared_ptr< transwarp::task_impl< TaskType, typename std::decay< Functor >::type, typename Parents::result_type... >>
 A factory function to create a new task.
 
template<typename TaskType , typename Functor , typename ParentType >
auto make_task (TaskType, Functor &&functor, std::vector< ParentType > parents) -> std::shared_ptr< transwarp::task_impl< TaskType, typename std::decay< Functor >::type, std::vector< ParentType >>>
 A factory function to create a new task with vector parents.
 
template<typename Value >
auto make_value_task (Value &&value) -> std::shared_ptr< transwarp::value_task< typename transwarp::decay< Value >::type >>
 A factory function to create a new value task.
 
template<typename InputIt , typename UnaryOperation >
auto for_each (InputIt first, InputIt last, UnaryOperation unary_op) -> std::shared_ptr< transwarp::task_impl< transwarp::wait_type, transwarp::no_op_functor, std::vector< std::shared_ptr< transwarp::task< void >>>>>
 A function similar to std::for_each but returning a transwarp task for deferred, possibly asynchronous execution. This function creates a graph with std::distance(first, last) root tasks.
 
template<typename InputIt , typename UnaryOperation >
auto for_each (transwarp::executor &executor, InputIt first, InputIt last, UnaryOperation unary_op) -> std::shared_ptr< transwarp::task_impl< transwarp::wait_type, transwarp::no_op_functor, std::vector< std::shared_ptr< transwarp::task< void >>>>>
 A function similar to std::for_each but returning a transwarp task for deferred, possibly asynchronous execution. This function creates a graph with std::distance(first, last) root tasks. Overload for automatic scheduling by passing an executor.
 
template<typename InputIt , typename OutputIt , typename UnaryOperation >
auto transform (InputIt first1, InputIt last1, OutputIt d_first, UnaryOperation unary_op) -> std::shared_ptr< transwarp::task_impl< transwarp::wait_type, transwarp::no_op_functor, std::vector< std::shared_ptr< transwarp::task< void >>>>>
 A function similar to std::transform but returning a transwarp task for deferred, possibly asynchronous execution. This function creates a graph with std::distance(first1, last1) root tasks.
 
template<typename InputIt , typename OutputIt , typename UnaryOperation >
auto transform (transwarp::executor &executor, InputIt first1, InputIt last1, OutputIt d_first, UnaryOperation unary_op) -> std::shared_ptr< transwarp::task_impl< transwarp::wait_type, transwarp::no_op_functor, std::vector< std::shared_ptr< transwarp::task< void >>>>>
 A function similar to std::transform but returning a transwarp task for deferred, possibly asynchronous execution. This function creates a graph with std::distance(first1, last1) root tasks. Overload for automatic scheduling by passing an executor.
 

Variables

constexpr transwarp::root_type root {}
 The root task tag.
 
constexpr transwarp::accept_type accept {}
 The accept task tag.
 
constexpr transwarp::accept_any_type accept_any {}
 The accept_any task tag.
 
constexpr transwarp::consume_type consume {}
 The consume task tag.
 
constexpr transwarp::consume_any_type consume_any {}
 The consume_any task tag.
 
constexpr transwarp::wait_type wait {}
 The wait task tag.
 
constexpr transwarp::wait_any_type wait_any {}
 The wait_any task tag.
 
constexpr no_op_functor no_op {}
 An object to use in places where a no-op functor is required.
 

Detailed Description

The transwarp namespace.

Enumeration Type Documentation

◆ event_type

enum transwarp::event_type
strong

The task events that can be subscribed to using the listener interface.

Enumerator
before_scheduled 

Just before a task is scheduled (handle_event called on thread of caller to schedule())

after_future_changed 

Just after the task's future was changed (handle_event called on thread that changed the task's future)

before_started 

Just before a task starts running (handle_event called on thread that task is run on)

before_invoked 

Just before a task's functor is invoked (handle_event called on thread that task is run on)

after_finished 

Just after a task has finished running (handle_event called on thread that task is run on)

after_canceled 

Just after a task was canceled (handle_event called on thread that task is run on)

after_satisfied 

Just after a task has satisfied all its children with results (handle_event called on thread where the last child is satisfied)

after_custom_data_set 

Just after custom data was assigned (handle_event called on thread that custom data was set on)

◆ task_type

enum transwarp::task_type
strong

The possible task types.

Enumerator
root 

The task has no parents.

accept 

The task's functor accepts all parent futures.

accept_any 

The task's functor accepts the first parent future that becomes ready.

consume 

The task's functor consumes all parent results.

consume_any 

The task's functor consumes the first parent result that becomes ready.

wait 

The task's functor takes no arguments but waits for all parents to finish.

wait_any 

The task's functor takes no arguments but waits for the first parent to finish.