C++ Actor Framework 1.0.0
Loading...
Searching...
No Matches
caf::flow::coordinator Class Referenceabstract

Coordinates any number of co-located observables and observers. More...

#include <coordinator.hpp>

Inheritance diagram for caf::flow::coordinator:
caf::async::execution_context caf::net::socket_manager

Public Types

using steady_time_point = std::chrono::steady_clock::time_point
 A time point of the monotonic clock.
 

Public Member Functions

observable_builder make_observable ()
 Returns a factory object for new observable objects on this coordinator.
 
template<class Impl , class... Args>
std::enable_if_t< std::is_base_of_v< coordinated, Impl >, intrusive_ptr< Impl > > add_child (std::in_place_type_t< Impl >, Args &&... args)
 Creates a new coordinated object on this coordinator.
 
template<class Impl , class... Args>
std::enable_if_t< std::is_base_of_v< coordinated, Impl >, typename Impl::handle_type > add_child_hdl (std::in_place_type_t< Impl > token, Args &&... args)
 Like add_child, but wraps the result in a handle type.
 
virtual void release_later (coordinated_ptr &child)=0
 Resets child and releases the reference count of the coordinated object at the end of the current cycle.
 
template<class T >
std::enable_if_t< std::is_base_of_v< coordinated, T > > release_later (intrusive_ptr< T > &child)
 Resets child and releases the reference count of the coordinated object at the end of the current cycle.
 
template<class Handle >
std::enable_if< Handle::holds_coordinated > release_later (Handle &hdl)
 Resets hdl and releases the reference count of the coordinated object at the end of the current cycle.
 
virtual steady_time_point steady_time ()=0
 Returns the current time on the monotonic clock of this coordinator.
 
virtual void delay (action what)=0
 Delays execution of an action until all pending actions were executed.
 
template<class F >
void delay_fn (F &&what)
 Delays execution of an action until all pending actions were executed.
 
virtual disposable delay_until (steady_time_point abs_time, action what)=0
 Delays execution of an action with an absolute timeout.
 
template<class F >
disposable delay_until_fn (steady_time_point abs_time, F &&what)
 Delays execution of an action until all pending actions were executed.
 
disposable delay_for (timespan rel_time, action what)
 Delays execution of an action with a relative timeout.
 
template<class F >
disposable delay_for_fn (timespan rel_time, F &&what)
 Delays execution of an action with a relative timeout.
 
- Public Member Functions inherited from caf::async::execution_context
virtual void ref_execution_context () const noexcept=0
 Increases the reference count of the execution_context.
 
virtual void deref_execution_context () const noexcept=0
 Decreases the reference count of the execution context and destroys the object if necessary.
 
virtual void schedule (action what)=0
 Schedules what to run on the event loop of the execution context.
 
template<class F >
void schedule_fn (F &&what)
 Schedules what to run on the event loop of the execution context.
 
virtual void watch (disposable what)=0
 Asks the coordinator to keep its event loop running until what becomes disposed since it depends on external events or produces events that are visible to outside observers.
 

Friends

template<class >
class observable
 

Related Symbols

(Note that these are not member symbols.)

using coordinator_ptr = intrusive_ptr<coordinator>
 

Detailed Description

Coordinates any number of co-located observables and observers.

The co-located objects never need to synchronize calls to other co-located objects since the coordinator guarantees synchronous execution.

Member Function Documentation

◆ add_child_hdl()

template<class Impl , class... Args>
std::enable_if_t< std::is_base_of_v< coordinated, Impl >, typename Impl::handle_type > caf::flow::coordinator::add_child_hdl ( std::in_place_type_t< Impl > token,
Args &&... args )
nodiscard

Like add_child, but wraps the result in a handle type.

The handle type depends on the coordinated object and usually one of observer<T>, observable<T>, or subscription.

◆ delay()

virtual void caf::flow::coordinator::delay ( action what)
pure virtual

Delays execution of an action until all pending actions were executed.

May call schedule.

Parameters
whatThe action for delayed execution.

◆ delay_fn()

template<class F >
void caf::flow::coordinator::delay_fn ( F && what)

Delays execution of an action until all pending actions were executed.

May call schedule.

Parameters
whatThe action for delayed execution.

◆ delay_for()

disposable caf::flow::coordinator::delay_for ( timespan rel_time,
action what )

Delays execution of an action with a relative timeout.

Parameters
rel_timeThe relative time when this action should take place.
whatThe action for delayed execution.
Returns
a disposable to cancel the pending timeout.

◆ delay_for_fn()

template<class F >
disposable caf::flow::coordinator::delay_for_fn ( timespan rel_time,
F && what )

Delays execution of an action with a relative timeout.

Parameters
rel_timeThe relative time when this action should take place.
whatThe action for delayed execution.
Returns
a disposable to cancel the pending timeout.

◆ delay_until()

virtual disposable caf::flow::coordinator::delay_until ( steady_time_point abs_time,
action what )
pure virtual

Delays execution of an action with an absolute timeout.

Parameters
abs_timeThe absolute time when this action should take place.
whatThe action for delayed execution.
Returns
a disposable to cancel the pending timeout.

◆ delay_until_fn()

template<class F >
disposable caf::flow::coordinator::delay_until_fn ( steady_time_point abs_time,
F && what )

Delays execution of an action until all pending actions were executed.

May call schedule.

Parameters
whatThe action for delayed execution.

◆ release_later() [1/3]

virtual void caf::flow::coordinator::release_later ( coordinated_ptr & child)
pure virtual

Resets child and releases the reference count of the coordinated object at the end of the current cycle.

Postcondition
child == nullptr

◆ release_later() [2/3]

template<class Handle >
std::enable_if< Handle::holds_coordinated > caf::flow::coordinator::release_later ( Handle & hdl)

Resets hdl and releases the reference count of the coordinated object at the end of the current cycle.

Postcondition
child == nullptr

◆ release_later() [3/3]

template<class T >
std::enable_if_t< std::is_base_of_v< coordinated, T > > caf::flow::coordinator::release_later ( intrusive_ptr< T > & child)

Resets child and releases the reference count of the coordinated object at the end of the current cycle.

Postcondition
child == nullptr

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