C++ Actor Framework  0.18
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
caf::stateful_actor< State, Base > Class Template Reference

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

#include <stateful_actor.hpp>

Inherits stateful_actor_base_t< State, Base >.

Collaboration diagram for caf::stateful_actor< State, Base >:
Collaboration graph

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. More...
 
const char * name () const override
 

Static Public Member Functions

template<class T >
static void non_static_name_member (const T &)
 

Public Attributes

union {
   State   state
 The actor's state. More...
 
}; 
 

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: