transwarp
Public Types | Public Member Functions | List of all members
transwarp::value_task< ResultType > Class Template Reference

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...

#include <transwarp.h>

Inheritance diagram for transwarp::value_task< ResultType >:
Inheritance graph
[legend]
Collaboration diagram for transwarp::value_task< ResultType >:
Collaboration graph
[legend]

Public Types

using task_type = transwarp::root_type
 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

template<typename T >
 value_task (T &&value)
 A value task is defined by a given value. Note: Don't use this constructor directly, use transwarp::make_value_task.
 
 value_task (const value_task &)=delete
 
value_taskoperator= (const value_task &)=delete
 
 value_task (value_task &&)=delete
 
value_taskoperator= (value_task &&)=delete
 
std::shared_ptr< value_tasknamed (std::string name)
 Gives this task a name and returns a ptr to itself.
 
template<typename TaskType_ , typename Functor_ >
auto then (TaskType_, Functor_ &&functor) -> std::shared_ptr< transwarp::task_impl< TaskType_, typename std::decay< Functor_ >::type, result_type >>
 Creates a continuation to this task.
 
std::shared_ptr< value_taskclone_cast () const
 Clones this task and casts the result to a ptr to value_task.
 
void finalize () override
 Nothing to be done to finalize a value task.
 
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
 Value tasks don't have executors as they don't run.
 
bool canceled () const noexcept override
 Value tasks cannot be canceled.
 
std::int64_t avg_idletime_us () const noexcept override
 Returns -1 as value tasks don't run.
 
std::int64_t avg_waittime_us () const noexcept override
 Returns -1 as value tasks don't run.
 
std::int64_t avg_runtime_us () const noexcept override
 Returns -1 as value tasks don't run.
 
void set_executor (std::shared_ptr< transwarp::executor >) override
 No-op because a value task never runs.
 
void set_executor_all (std::shared_ptr< transwarp::executor >) override
 No-op because a value task never runs and doesn't have parents.
 
void remove_executor () override
 No-op because a value task never runs.
 
void remove_executor_all () override
 No-op because a value task never runs and doesn't have parents.
 
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.
 
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.
 
void remove_custom_data_all () override
 Removes custom data from all tasks.
 
void schedule () override
 No-op because a value task never runs.
 
void schedule (transwarp::executor &) override
 No-op because a value task never runs.
 
void schedule (bool) override
 No-op because a value task never runs.
 
void schedule (transwarp::executor &, bool) override
 No-op because a value task never runs.
 
void schedule_all () override
 No-op because a value task never runs and doesn't have parents.
 
void schedule_all (transwarp::executor &) override
 No-op because a value task never runs and doesn't have parents.
 
void schedule_all (bool) override
 No-op because a value task never runs and doesn't have parents.
 
void schedule_all (transwarp::executor &, bool) override
 No-op because a value task never runs and doesn't have parents.
 
void set_value (const typename transwarp::decay< result_type >::type &value) override
 Assigns a value to this task.
 
void set_value (typename transwarp::decay< result_type >::type &&value) override
 Assigns a value to this task.
 
void set_exception (std::exception_ptr exception) override
 Assigns an exception to this task.
 
transwarp::result< result_type >::type get () const override
 Returns the value of this task. Throws an exception if this task has an exception assigned to it.
 
bool was_scheduled () const noexcept override
 Returns true because a value task is scheduled once on construction.
 
void wait () const override
 No-op because a value task never runs.
 
bool is_ready () const override
 Returns true because a value task is always ready.
 
bool has_result () const noexcept override
 Returns true because a value task always contains a result.
 
void reset () override
 No-op because a value task never runs.
 
void reset_all () override
 No-op because a value task never runs and doesn't have parents.
 
void cancel (bool) noexcept override
 No-op because a value task never runs.
 
void cancel_all (bool) noexcept override
 No-op because a value task never runs and doesn't have parents.
 
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
 Empty because a value task doesn't have parents.
 
const std::vector< transwarp::itask * > & tasks () override
 Returns all tasks in the graph in breadth order.
 
std::vector< transwarp::edgeedges () override
 Returns empty edges because a value task doesn't have parents.
 
- 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
 

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 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)
 
- Protected Attributes inherited from transwarp::detail::task_common< ResultType >
std::size_t id_ = 0
 
transwarp::option_str name_
 
std::int64_t priority_ = 0
 
transwarp::any_data custom_data_
 
std::shared_future< result_typefuture_
 
bool visited_ = false
 
std::unique_ptr< listeners_t > listeners_
 
std::unique_ptr< tasks_t > tasks_
 

Detailed Description

template<typename ResultType>
class transwarp::value_task< ResultType >

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.


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