Class base_executive

Inheritance Relationships

Base Type

  • public rer::client< base_executive >

Derived Type

Class Documentation

class base_executive : public rer::client<base_executive>

Base class for runtime task task executives. Supports specification of task allocation policy independent from the data structure storing relationships among the tasks to be allocated (invalid combinations result in compiler errors).

Subclassed by cosm::ta::bi_tdgraph_executive

Public Types

using abort_notify_cb = std::function<void(polled_task*)>
using finish_notify_cb = std::function<void(polled_task*)>
using start_notify_cb = std::function<void(polled_task*)>

Public Functions

base_executive(const base_executive&) = delete
base_executive(const config::task_executive_config *exec_config, const config::task_alloc_config *alloc_config, ds::ds_variant &&ds, rmath::rng *rng)

Creates the base executive.

Parameters:
  • exec_config – Initialization config specific to executive.

  • alloc_config – Initialization config for task allocation.

  • ds – Data structure containing tasks to manage/run.

  • rng – Non-owning Random number generator reference.

~base_executive(void) override
inline const config::task_alloc_config *alloc_config(void) const
inline polled_task *current_task(void)
inline const polled_task *current_task(void) const

Get the task currently being run.

inline const ds::ds_variant *ds(void) const
base_executive &operator=(const base_executive&) = delete
void run(void)

The means by which the task executive will run one timestep.

inline void task_abort_notify(const abort_notify_cb &cb)

Set an optional callback that will be run when a task is aborted.

The callback will be passed the task that was aborted, before the active task is reset and after any time estimates have been updated on the aborted task (the task is marked as aborted before calling).

inline const std::list<abort_notify_cb> &task_abort_notify(void) const
inline void task_finish_notify(const finish_notify_cb &cb)

Set an optional callback that will be run when after a task is finished.

The callback will be passed a pointer to the task that was just finished, before the task is reset and after time estimates are updated on the finished task. The task will have its execution and interface times updated (if applicable) prior to the call.

inline const std::list<finish_notify_cb> &task_finish_notify(void) const
inline void task_start_notify(const start_notify_cb &cb)

Set an optional callback that will be run when a task is started.

The callback will be passed a pointer to the task that was just started, before the task is reset.

inline const std::list<start_notify_cb> &task_start_notify(void) const
inline bool update_exec_ests(void) const
inline bool update_interface_ests(void) const

Protected Functions

inline void current_task(polled_task *current_task)
void do_task_start(polled_task *task)

Low-level start start handling:

  • Reset the task.

  • Actually start the task.

  • Set the current task for the executive to the started task.

inline ds::ds_variant *ds(void)
inline rmath::rng *rng(void)
inline const rmath::rng *rng(void) const
virtual void task_abort_handle(polled_task *task)

Handler called when a task is aborted.

The base implementation does the following, in order:

  • Update exec/interface times, time estimates.

  • Mark the task as aborted.

  • Call the task abort callbacks with the aborted task.

  • Mark the task as not aborted.

  • Start a new task via task_start_handle().

inline size_t task_alloc_count(void) const
virtual polled_task *task_allocate(const polled_task *task) = 0

Allocate a new task, given the most recently executed one.

void task_ests_update(polled_task *task)

Update execution and interface time estimates (if configured to do so) for the specified task.

virtual void task_finish_handle(polled_task *task)

Handler called when a task has been finished (not aborted).

The base implementation does the following, in order:

  • Update task exec/interface times/estimates

  • Call the task finish callbacks for the finished task.

  • Start a new task via task_start_handle().

virtual void task_start_handle(polled_task *new_task)

Handler called to start a new task.

The base implementation does the following, in order:

  • Call the task start callbacks for the new task.

  • Call do_task_start() for the new task.

void task_times_update(polled_task *task)

Update execution and interface times for the specified task.