transwarp
Public Types | Public Member Functions | Protected Member Functions | List of all members
transwarp::detail::task_impl_proxy< ResultType &, TaskType, Functor, ParentResults... > Class Template Reference

A task proxy for reference result type. More...

#include <transwarp.h>

Inheritance diagram for transwarp::detail::task_impl_proxy< ResultType &, TaskType, Functor, ParentResults... >:
Inheritance graph
[legend]
Collaboration diagram for transwarp::detail::task_impl_proxy< ResultType &, TaskType, Functor, ParentResults... >:
Collaboration graph
[legend]

Public Types

using task_type = TaskType
 The task type.
 
using result_type = ResultType &
 The result type of this task.
 
- Public Types inherited from transwarp::detail::task_impl_base< ResultType &, TaskType, Functor, ParentResults... >
using task_type = TaskType
 The task type.
 
using result_type = ResultType &
 The result type of this task.
 
- Public Types inherited from transwarp::detail::task_common< ResultType & >
using result_type = ResultType &
 The result type of this task.
 
- Public Types inherited from transwarp::task< ResultType & >
using result_type = ResultType &
 

Public Member Functions

void set_value (typename transwarp::decay< result_type >::type &value) override
 Assigns a value to this task. Scheduling will have no effect after a value has been set. Calling reset() will remove the value and re-enable scheduling.
 
transwarp::result< result_type >::type get () const override
 Returns the result of this task. Throws any exceptions that the underlying functor throws. Should only be called if was_scheduled() is true, throws transwarp::control_error otherwise.
 
- Public Member Functions inherited from transwarp::detail::task_impl_base< ResultType &, TaskType, Functor, ParentResults... >
void finalize () override
 Can be called to explicitly finalize this task making this task the terminal task in the graph. This is also done implicitly when calling, e.g., any of the *_all methods. It should normally not be necessary to call this method directly.
 
std::size_t level () const noexcept override
 The task's level.
 
transwarp::task_type type () const noexcept override
 The task's type.
 
std::shared_ptr< transwarp::executorexecutor () const noexcept override
 The task's executor (may be null)
 
bool canceled () const noexcept override
 Returns whether the associated task is canceled.
 
std::int64_t avg_idletime_us () const noexcept override
 Returns the average idletime in microseconds (-1 if never set)
 
std::int64_t avg_waittime_us () const noexcept override
 Returns the average waittime in microseconds (-1 if never set)
 
std::int64_t avg_runtime_us () const noexcept override
 Returns the average runtime in microseconds (-1 if never set)
 
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 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 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 noexcept override
 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 noexcept override
 Returns whether this task contains a result.
 
void reset () override
 Resets this task.
 
void reset_all () override
 Resets all tasks in the graph.
 
void cancel (bool enabled) noexcept override
 If enabled then this task is canceled which will throw transwarp::task_canceled when retrieving the task result. Passing false is equivalent to resume.
 
void cancel_all (bool enabled) noexcept override
 If enabled then all pending tasks in the graph are canceled which will throw transwarp::task_canceled when retrieving the task result. Passing false is equivalent to resume.
 
void set_priority_all (std::int64_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_all () override
 Resets the priority of all tasks to 0.
 
void set_custom_data_all (transwarp::any_data 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_all () override
 Removes custom data from all tasks.
 
void add_listener_all (std::shared_ptr< transwarp::listener > listener) override
 Adds a new listener for all event types and for all parents.
 
void add_listener_all (transwarp::event_type event, std::shared_ptr< transwarp::listener > listener) override
 Adds a new listener for the given event type only and for all parents.
 
void remove_listener_all (const std::shared_ptr< transwarp::listener > &listener) override
 Removes the listener for all event types and for all parents.
 
void remove_listener_all (transwarp::event_type event, const std::shared_ptr< transwarp::listener > &listener) override
 Removes the listener for the given event type only and for all parents.
 
void remove_listeners_all () override
 Removes all listeners and for all parents.
 
void remove_listeners_all (transwarp::event_type event) override
 Removes all listeners for the given event type and for all parents.
 
std::vector< transwarp::itask * > parents () const override
 Returns the task's parents (may be empty)
 
const std::vector< transwarp::itask * > & tasks () override
 Returns all tasks in the graph in breadth order.
 
std::vector< transwarp::edgeedges () override
 Returns all edges in the graph. 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.
 
- Public Member Functions inherited from transwarp::detail::task_common< ResultType & >
std::size_t id () const noexcept override
 The task's id.
 
const transwarp::option_str & name () const noexcept override
 The optional task name.
 
std::int64_t priority () const noexcept override
 The task priority (defaults to 0)
 
const transwarp::any_data & custom_data () const noexcept override
 The custom task data (may not hold a value)
 
void set_priority (std::int64_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 reset_priority () override
 Resets the task priority to 0.
 
void set_custom_data (transwarp::any_data 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 remove_custom_data () override
 Removes custom data from this task.
 
std::shared_future< result_typefuture () const noexcept override
 Returns the future associated to the underlying execution.
 
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 () override
 Removes all listeners.
 
void remove_listeners (transwarp::event_type event) override
 Removes all listeners for the given event type.
 
- Public Member Functions inherited from transwarp::task< ResultType & >
std::shared_ptr< taskclone () const
 
virtual std::shared_future< result_type > future () const noexcept=0
 
- Public Member Functions inherited from transwarp::itask
virtual std::size_t id () const noexcept=0
 
virtual std::size_t level () const noexcept=0
 
virtual transwarp::task_type type () const noexcept=0
 
virtual const transwarp::option_str & name () const noexcept=0
 
virtual std::shared_ptr< transwarp::executorexecutor () const noexcept=0
 
virtual std::int64_t priority () const noexcept=0
 
virtual const transwarp::any_data & custom_data () const noexcept=0
 
virtual bool canceled () const noexcept=0
 
virtual std::int64_t avg_idletime_us () const noexcept=0
 
virtual std::int64_t avg_waittime_us () const noexcept=0
 
virtual std::int64_t avg_runtime_us () const noexcept=0
 
virtual bool was_scheduled () const noexcept=0
 
virtual void wait () const =0
 
virtual bool is_ready () const =0
 
virtual bool has_result () const =0
 
virtual std::vector< itask * > parents () const =0
 

Protected Member Functions

template<typename F >
 task_impl_proxy (F &&functor, std::shared_ptr< transwarp::task< ParentResults >>... parents)
 
template<typename F , typename P >
 task_impl_proxy (F &&functor, std::vector< std::shared_ptr< transwarp::task< P >>> parents)
 
- Protected Member Functions inherited from transwarp::detail::task_impl_base< ResultType &, TaskType, Functor, ParentResults... >
 task_impl_base (F &&functor, std::shared_ptr< transwarp::task< ParentResults >>... parents)
 
 task_impl_base (F &&functor, std::vector< std::shared_ptr< transwarp::task< P >>> parents)
 
void init ()
 
void set_level (std::size_t level) noexcept override
 Assigns the given level.
 
void set_type (transwarp::task_type type) noexcept override
 Assigns the given type.
 
void set_avg_idletime_us (std::int64_t idletime) noexcept override
 Assigns the given idletime.
 
void set_avg_waittime_us (std::int64_t waittime) noexcept override
 Assigns the given waittime.
 
void set_avg_runtime_us (std::int64_t runtime) noexcept override
 Assigns the given runtime.
 
void ensure_task_was_scheduled () const
 Checks if the task was scheduled and throws transwarp::control_error if it's not.
 
void schedule_impl (bool reset, transwarp::executor *executor=nullptr) override
 Schedules this task for execution using the provided executor. The task-specific executor gets precedence if it exists. Runs the task on the same thread as the caller if neither the global nor the task-specific executor is found.
 
void schedule_all_impl (bool reset_all, transwarp::executor *executor=nullptr)
 Schedules all tasks in the graph for execution using the provided executor. The task-specific executors get precedence if they exist. Runs tasks on the same thread as the caller if neither the global nor a task-specific executor is found.
 
void visit (const std::function< void(transwarp::itask &)> &visitor) override
 Visits each task in a depth-first traversal.
 
void unvisit () noexcept override
 Traverses through each task and marks them as not visited.
 
void visit_all (Visitor &visitor)
 Visits all tasks.
 
void increment_childcount () noexcept override
 
void decrement_refcount () override
 
void reset_future () override
 
- Protected Member Functions inherited from transwarp::detail::task_common< ResultType & >
void ensure_task_not_running () const
 Checks if the task is currently running and throws transwarp::control_error if it is.
 
void raise_event (transwarp::event_type event)
 Raises the given event to all listeners.
 
void check_listener (const std::shared_ptr< transwarp::listener > &listener) const
 Check for non-null listener pointer.
 
void ensure_listeners_object ()
 
void set_id (std::size_t id) noexcept override
 Assigns the given id.
 
void set_name (transwarp::option_str name) noexcept override
 Assigns the given name.
 
void copy_from (const task_common &task)
 

Additional Inherited Members

- Protected Types inherited from transwarp::detail::task_common< ResultType & >
using listeners_t = std::map< transwarp::event_type, std::vector< std::shared_ptr< transwarp::listener > >>
 
using tasks_t = std::vector< transwarp::itask * >
 
- Protected Attributes inherited from transwarp::detail::task_impl_base< ResultType &, TaskType, Functor, ParentResults... >
std::size_t level_
 
transwarp::task_type type_
 
std::shared_ptr< transwarp::executorexecutor_
 
std::atomic< bool > canceled_
 
bool schedule_mode_
 
std::atomic< std::int64_t > avg_idletime_us_
 
std::atomic< std::int64_t > avg_waittime_us_
 
std::atomic< std::int64_t > avg_runtime_us_
 
std::unique_ptr< Functor > functor_
 
transwarp::detail::parents< ParentResults... >::type parents_
 
std::size_t childcount_
 
std::atomic< std::size_t > refcount_
 
- Protected Attributes inherited from transwarp::detail::task_common< ResultType & >
std::size_t id_
 
transwarp::option_str name_
 
std::int64_t priority_
 
transwarp::any_data custom_data_
 
std::shared_future< result_typefuture_
 
bool visited_
 
std::unique_ptr< listeners_t > listeners_
 
std::unique_ptr< tasks_t > tasks_
 

Detailed Description

template<typename ResultType, typename TaskType, typename Functor, typename... ParentResults>
class transwarp::detail::task_impl_proxy< ResultType &, TaskType, Functor, ParentResults... >

A task proxy for reference result type.


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