AIStatefulTask ‐ Asynchronous, Stateful Task Scheduler library.

Threads-like task objects evolving through user-defined states.

Classes | Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | List of all members
task::Broker< Task, Args > Class Template Reference
Inheritance diagram for task::Broker< Task, Args >:
Inheritance graph
[legend]
Collaboration diagram for task::Broker< Task, Args >:
Collaboration graph
[legend]

Public Member Functions

 Broker (bool debug) Args... task_args)
 
void run (AIStatefulTask::Handler handler=AIStatefulTask::Handler::immediate)
 
void terminate ()
 
void terminate (std::function< void(Task *)> callback)
 
boost::intrusive_ptr< Task const > run (statefultask::BrokerKey const &key, std::function< void(bool)> &&callback)
 
- Public Member Functions inherited from AIStatefulTask
Conditions print_conditions (condition_type conditions)
 
 AIStatefulTask (bool debug)
 
void run (Handler default_handler, std::function< void(bool)> cb_function)
 
void run (std::function< void(bool)> cb_function)
 The same as above but use the immediate Handler.
 
void run (Handler default_handler, AIStatefulTask *parent, condition_type condition, on_abort_st on_abort=abort_parent)
 
void run (AIStatefulTask *parent, condition_type condition, on_abort_st on_abort=abort_parent)
 
void run (Handler default_handler=Handler::immediate)
 
void kill ()
 
void abort ()
 
bool signal (condition_type condition)
 
bool running () const
 
bool waiting () const
 
bool waiting_or_aborting () const
 
bool active (Handler handler) const
 
bool is_immediate () const
 
bool finished () const
 
bool aborted () const
 
bool executing () const
 
duration_type getDuration () const
 
char const * task_name () const
 

Static Public Attributes

static constexpr state_type state_end = Broker_do_work + 1
 
- Static Public Attributes inherited from AIStatefulTask
static constexpr condition_type slow_down_condition = 0x40000000
 
static constexpr condition_type thread_pool_full_condition = 0x80000000
 
static constexpr condition_type AND_conditions_mask = 0xf0000000
 
static constexpr condition_type OR_conditions_mask = 0x0fffffff
 
static constexpr state_type state_end = bs_killed + 1
 The next state value to use for derived classes.
 

Protected Types

enum  broker_state_type { Broker_start = direct_base_type::state_end , Broker_do_work }
 
using direct_base_type = AIStatefulTask
 
- Protected Types inherited from AIStatefulTask
enum  base_state_type {
  bs_reset , bs_initialize , bs_multiplex , bs_abort ,
  bs_finish , bs_callback , bs_killed
}
 The type of mState. More...
 

Protected Member Functions

char const * state_str_impl (state_type run_state) const override
 Called to stringify a run state for debugging output. Must be overridden. More...
 
char const * task_name_impl () const override
 This can be used to get a human readable name of the most-derived class. It must be guaranteed to always return the same pointer value so it can be used with Tracy (for example). More...
 
void multiplex_impl (state_type run_state) override
 Called for base state bs_multiplex. More...
 
void abort_impl () override
 Called for base state bs_abort. More...
 
- Protected Member Functions inherited from AIStatefulTask
virtual ~AIStatefulTask ()
 Destructor.
 
void set_state (state_type new_state)
 
void wait (condition_type conditions)
 
void wait_until (AIWaitConditionFunc const &wait_condition, condition_type conditions)
 
void wait_until (AIWaitConditionFunc const &wait_condition, condition_type conditions, state_type new_state)
 
void finish ()
 
utils::FuzzyBool is_self_locked (AIStatefulTaskMutex const &stateful_task_mutex, AIStatefulTaskMutexNode const *handle)
 
void yield ()
 
void target (Handler handler)
 
void yield (Handler handler)
 
void yield_frame (AIEngine *engine, unsigned int frames)
 
void yield_ms (AIEngine *engine, unsigned int ms)
 
bool yield_if_not (Handler handler)
 
virtual char const * condition_str_impl (condition_type condition) const
 Called to stringify a condition type for debugging output. More...
 
virtual void initialize_impl ()
 Called for base state bs_initialize. More...
 
virtual void finish_impl ()
 Called for base state bs_finish. More...
 
virtual void force_killed ()
 Called from AIEngine::flush(). More...
 

Additional Inherited Members

- Public Types inherited from AIStatefulTask
enum  on_abort_st { abort_parent , signal_parent , do_nothing }
 What to do when a child task is aborted. More...
 
using state_type = uint32_t
 The type of run_state.
 
using condition_type = uint32_t
 The type of the skip_wait and idle bit masks.
 
- Static Public Member Functions inherited from AIStatefulTask
static char const * state_str (base_state_type state)
 

Member Function Documentation

◆ abort_impl()

template<TaskType Task, typename... Args>
void task::Broker< Task, Args >::abort_impl
overrideprotectedvirtual

Called for base state bs_abort.

Reimplemented from AIStatefulTask.

◆ multiplex_impl()

template<TaskType Task, typename... Args>
void task::Broker< Task, Args >::multiplex_impl ( state_type  run_state)
overrideprotectedvirtual

Called for base state bs_multiplex.

Implements AIStatefulTask.

◆ state_str_impl()

template<TaskType Task, typename... Args>
char const * task::Broker< Task, Args >::state_str_impl ( state_type  run_state) const
overrideprotectedvirtual

Called to stringify a run state for debugging output. Must be overridden.

Reimplemented from AIStatefulTask.

◆ task_name_impl()

template<TaskType Task, typename... Args>
char const * task::Broker< Task, Args >::task_name_impl ( ) const
overrideprotectedvirtual

This can be used to get a human readable name of the most-derived class. It must be guaranteed to always return the same pointer value so it can be used with Tracy (for example).

Implements AIStatefulTask.


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