C++ Actor Framework 0.18
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
caf::action Class Reference

A functional interface similar to std::function<void()> with dispose semantics. More...

#include <action.hpp>

Classes

class  impl
 Internal interface of action. More...
 

Public Types

enum class  state {
  disposed ,
  scheduled ,
  invoked ,
  waiting
}
 Describes the current state of an action. More...
 
enum class  transition {
  success ,
  disposed ,
  failure
}
 Describes the result of an attempted state transition. More...
 
using impl_ptr = intrusive_ptr< impl >
 

Public Member Functions

 action (impl_ptr ptr) noexcept
 
 action (action &&) noexcept=default
 
 action (const action &) noexcept=default
 
actionoperator= (action &&) noexcept=default
 
actionoperator= (const action &) noexcept=default
 
bool disposed () const
 
bool scheduled () const
 
bool invoked () const
 
transition run ()
 Tries to transition from scheduled to invoked, running the body of the internal function object as a side effect on success.
 
void dispose ()
 Cancel the action if it has not been invoked yet.
 
transition reschedule ()
 Tries setting the state from invoked back to scheduled.
 
disposable as_disposable () &&noexcept
 Returns a smart pointer to the implementation.
 
disposable as_disposable () const &noexcept
 Returns a smart pointer to the implementation.
 
implptr () const noexcept
 Returns a pointer to the implementation.
 
impl_ptr && as_intrusive_ptr () &&noexcept
 Returns a smart pointer to the implementation.
 
impl_ptr as_intrusive_ptr () const &noexcept
 Returns a smart pointer to the implementation.
 

Detailed Description

A functional interface similar to std::function<void()> with dispose semantics.

Member Enumeration Documentation

◆ state

enum class caf::action::state
strong

Describes the current state of an action.

Enumerator
scheduled 

The action may no longer run.

invoked 

The action is scheduled for execution.

waiting 

The action fired and needs rescheduling before running again.

◆ transition

enum class caf::action::transition
strong

Describes the result of an attempted state transition.

Enumerator
disposed 

Transition completed as expected.

failure 

No transition since the action has been disposed.

Member Function Documentation

◆ reschedule()

transition caf::action::reschedule ( )

Tries setting the state from invoked back to scheduled.

Returns
whether the transition took place.

◆ run()

transition caf::action::run ( )

Tries to transition from scheduled to invoked, running the body of the internal function object as a side effect on success.

Returns
whether the transition took place.

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