The base task class that contains the functionality that can be used with all result types (void and non-void) which is almost everything. More...
#include <transwarp.h>
Public Types | |
using | task_type = TaskType |
The task type. | |
using | result_type = ResultType |
The result type of this task. | |
![]() | |
using | result_type = ResultType |
Public Member Functions | |
void | set_executor (std::shared_ptr< transwarp::executor > executor) override |
Assigns an executor to this task which takes precedence over the executor provided in schedule() or schedule_all() | |
void | set_executor_all (std::shared_ptr< transwarp::executor > executor) override |
Assigns an executor to all tasks which takes precedence over the executor provided in schedule() or schedule_all() | |
void | remove_executor () override |
Removes the executor from this task. | |
void | remove_executor_all () override |
Removes the executor from all tasks. | |
void | set_priority (std::size_t priority) override |
Sets a task priority (defaults to 0). transwarp will not directly use this. This is only useful if something else is using the priority (e.g. a custom executor) | |
void | set_priority_all (std::size_t priority) override |
Sets a priority to all tasks (defaults to 0). transwarp will not directly use this. This is only useful if something else is using the priority (e.g. a custom executor) | |
void | reset_priority () override |
Resets the task priority to 0. | |
void | reset_priority_all () override |
Resets the priority of all tasks to 0. | |
void | set_custom_data (std::shared_ptr< void > custom_data) override |
Assigns custom data to this task. transwarp will not directly use this. This is only useful if something else is using this custom data (e.g. a custom executor) | |
void | set_custom_data_all (std::shared_ptr< void > custom_data) override |
Assigns custom data to all tasks. transwarp will not directly use this. This is only useful if something else is using this custom data (e.g. a custom executor) | |
void | remove_custom_data () override |
Removes custom data from this task. | |
void | remove_custom_data_all () override |
Removes custom data from all tasks. | |
const std::shared_future < result_type > & | get_future () const noexceptoverride |
Returns the future associated to the underlying execution. | |
const std::shared_ptr < transwarp::node > & | get_node () const noexceptoverride |
Returns the associated node. | |
void | add_listener (std::shared_ptr< transwarp::listener > listener) override |
Adds a new listener for all event types. | |
void | add_listener (transwarp::event_type event, std::shared_ptr< transwarp::listener > listener) override |
Adds a new listener for the given event type only. | |
void | remove_listener (const std::shared_ptr< transwarp::listener > &listener) override |
Removes the listener for all event types. | |
void | remove_listener (transwarp::event_type event, const std::shared_ptr< transwarp::listener > &listener) override |
Removes the listener for the given event type only. | |
void | remove_listeners (transwarp::event_type event) override |
Removes all listeners for the given event type. | |
void | remove_listeners () override |
Removes all listeners. | |
void | schedule () override |
Schedules this task for execution on the caller thread. The task-specific executor gets precedence if it exists. This overload will reset the underlying future. | |
void | schedule (bool reset) override |
Schedules this task for execution on the caller thread. The task-specific executor gets precedence if it exists. reset denotes whether schedule should reset the underlying future and schedule even if the future is already valid. | |
void | schedule (transwarp::executor &executor) override |
Schedules this task for execution using the provided executor. The task-specific executor gets precedence if it exists. This overload will reset the underlying future. | |
void | schedule (transwarp::executor &executor, bool reset) override |
Schedules this task for execution using the provided executor. The task-specific executor gets precedence if it exists. reset denotes whether schedule should reset the underlying future and schedule even if the future is already valid. | |
void | schedule_all () override |
Schedules all tasks in the graph for execution on the caller thread. The task-specific executors get precedence if they exist. This overload will reset the underlying futures. | |
void | schedule_all (transwarp::executor &executor) override |
Schedules all tasks in the graph for execution using the provided executor. The task-specific executors get precedence if they exist. This overload will reset the underlying futures. | |
void | schedule_all (bool reset_all) override |
Schedules all tasks in the graph for execution on the caller thread. The task-specific executors get precedence if they exist. reset_all denotes whether schedule_all should reset the underlying futures and schedule even if the futures are already present. | |
void | schedule_all (transwarp::executor &executor, bool reset_all) override |
Schedules all tasks in the graph for execution using the provided executor. The task-specific executors get precedence if they exist. reset_all denotes whether schedule_all should reset the underlying futures and schedule even if the futures are already present. | |
void | schedule_all (transwarp::schedule_type type) override |
Schedules all tasks in the graph for execution on the caller thread. The task-specific executors get precedence if they exist. This overload will reset the underlying futures. | |
void | schedule_all (transwarp::executor &executor, transwarp::schedule_type type) override |
Schedules all tasks in the graph for execution using the provided executor. The task-specific executors get precedence if they exist. This overload will reset the underlying futures. | |
void | schedule_all (transwarp::schedule_type type, bool reset_all) override |
Schedules all tasks in the graph for execution on the caller thread. The task-specific executors get precedence if they exist. reset_all denotes whether schedule_all should reset the underlying futures and schedule even if the futures are already present. | |
void | schedule_all (transwarp::executor &executor, transwarp::schedule_type type, bool reset_all) override |
Schedules all tasks in the graph for execution using the provided executor. The task-specific executors get precedence if they exist. reset_all denotes whether schedule_all should reset the underlying futures and schedule even if the futures are already present. | |
void | set_exception (std::exception_ptr exception) override |
Assigns an exception to this task. Scheduling will have no effect after an exception has been set. Calling reset() will remove the exception and re-enable scheduling. | |
bool | was_scheduled () const noexceptoverride |
Returns whether the task was scheduled and not reset afterwards. This means that the underlying future is valid. | |
void | wait () const override |
Waits for the task to complete. Should only be called if was_scheduled() is true, throws transwarp::control_error otherwise. | |
bool | is_ready () const override |
Returns whether the task has finished processing. Should only be called if was_scheduled() is true, throws transwarp::control_error otherwise. | |
bool | has_result () const noexceptoverride |
Returns whether this task contains a result. | |
void | reset () override |
Resets the future of this task. | |
void | reset_all () override |
Resets the futures of all tasks in the graph. | |
void | cancel (bool enabled) noexceptoverride |
If enabled then this task is canceled which will throw transwarp::task_canceled when retrieving the task result. As long as cancel is enabled new computations cannot be scheduled. Passing false is equivalent to resume. | |
void | cancel_all (bool enabled) noexceptoverride |
If enabled then all pending tasks in the graph are canceled which will throw transwarp::task_canceled when retrieving the task result. As long as cancel is enabled new computations cannot be scheduled. Passing false is equivalent to resume. | |
std::vector< transwarp::edge > | get_graph () const override |
Returns the graph of the task structure. This is mainly for visualizing the tasks and their interdependencies. Pass the result into transwarp::to_string to retrieve a dot-style graph representation for easy viewing. | |
![]() | |
virtual void | set_value (const typename transwarp::decay< result_type >::type &value)=0 |
virtual void | set_value (typename transwarp::decay< result_type >::type &&value)=0 |
virtual transwarp::result_info < result_type >::type | get () const =0 |
Protected Member Functions | |
template<typename F > | |
task_impl_base (bool has_name, std::string name, F &&functor, std::shared_ptr< transwarp::task< ParentResults >>...parents) | |
void | ensure_task_not_running () const |
Checks if the task is currently running and throws transwarp::control_error if it is. | |
void | ensure_task_was_scheduled () const |
Checks if the task was scheduled and throws transwarp::control_error if it's not. | |
Protected Attributes | |
bool | schedule_mode_ = true |
std::shared_future< result_type > | future_ |
Friends | |
template<typename R , typename T , typename... A> | |
R | transwarp::detail::run_task (std::size_t, const T &, A &&...) |
The base task class that contains the functionality that can be used with all result types (void and non-void) which is almost everything.