Template Struct subtask

Struct Documentation

template<typename ActivityT, typename ...DependenciesT>
struct udho::activities::subtask

A subtask is an instantiation of an activity. The subtask reuses an activity to model different use cases by attaching dependencies. A subtask contains two shared pointers, one to the activity and another one to the combinator. The subtask cannot be instantiated directly by calling the subtask constructor. Instead call the static with method to instantiate.

Template Parameters
  • ActivityT: The activity

  • DependenciesT: The activities that has to be performed before performing ActivityT

Public Types

typedef ActivityT activity_type
typedef combinator<ActivityT, DependenciesT...> combinator_type
typedef subtask<ActivityT, DependenciesT...> self_type

Public Functions

subtask(const self_type &other)
std::shared_ptr<activity_type> activity()

shared pointer to the activity

template<typename V, typename ...DependenciesV>
self_type &done(subtask<V, DependenciesV...> &next)

execute task next after the current one

Parameters
  • next: the next subtask

template<typename V, typename ...DependenciesV>
self_type &after(subtask<V, DependenciesV...> &previous)

t2.after(t1) is equivalent to t1.done(t2)

Parameters
  • previous: the previous subtask

template<typename PreparatorT>
self_type &prepare(PreparatorT prep)

attach a callback which will be called with a reference to the activity after it has been instantiated and all its dependencies have completed.

self_type &required(bool flag)

Set required flag on or off. If a required subtask fails then all intermediate subtask that depend on it fails and the final callback is called immediately. By default all subtasks are required

self_type &cancel_if(typename activity_type::cancel_if_ftor cancelor)

Force cancelation of the activity even after it is successful to stop propagating to the next activities

Parameters
  • f: callback which should return true to signal cancelation

std::shared_ptr<activity_type> operator->()

returns the shared pointer to the actiivity

template<typename FunctionT>
self_type &if_errored(FunctionT ftor)

abort if canceled if ftor returns false. f will be called with the success if it has been canceled due to error

template<typename FunctionT>
self_type &if_failed(FunctionT ftor)

abort if canceled if ftor returns false. f will be called with the failue data if it has been canceled due to failure

template<typename FunctionT>
self_type &if_canceled(FunctionT ftor)

Public Static Functions

template<typename CollectorT, typename ...U>
self_type with(CollectorT collector, U&&... u)

Arguments for the constructor of the Activity

Friends

friend struct subtask