C++ Actor Framework 1.0.0
Loading...
Searching...
No Matches
caf::stateful_actor< State, Base > Class Template Reference

An event-based actor with managed state. More...

#include <stateful_actor.hpp>

Inherits detail::stateful_actor_base_t< State, Base >.

Public Types

using super = detail::stateful_actor_base_t<State, Base>
 

Public Member Functions

template<class... Ts>
 stateful_actor (actor_config &cfg, Ts &&... xs)
 
void on_exit () override
 Can be overridden to perform cleanup code after an actor finished execution.
 
const char * name () const override
 
State & state ()
 Returns a reference to the actor's state.
 

Detailed Description

template<class State, class Base>
class caf::stateful_actor< State, Base >

An event-based actor with managed state.

The state is constructed with the actor, but destroyed when the actor calls quit. This state management brakes cycles and allows actors to automatically release resources as soon as possible.

Member Function Documentation

◆ on_exit()

template<class State , class Base >
void caf::stateful_actor< State, Base >::on_exit ( )
override

Can be overridden to perform cleanup code after an actor finished execution.

Note
when overriding this member function, make sure to call super::on_exit() in order to clean up the state.

Member Data Documentation

◆ state_

template<class State , class Base >
State caf::stateful_actor< State, Base >::state_

The actor's state.

This member lives inside a union since its lifetime ends when the actor terminates while the actual actor object lives until its reference count drops to zero.


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