Kagome
Polkadot Runtime Engine in C++17
kagome::application::AppStateManagerImpl Class Reference

#include <app_state_manager_impl.hpp>

Inheritance diagram for kagome::application::AppStateManagerImpl:
Collaboration diagram for kagome::application::AppStateManagerImpl:

Public Member Functions

 AppStateManagerImpl ()
 
 AppStateManagerImpl (const AppStateManagerImpl &)=delete
 
 AppStateManagerImpl (AppStateManagerImpl &&) noexcept=delete
 
 ~AppStateManagerImpl () override
 
AppStateManagerImploperator= (AppStateManagerImpl const &)=delete
 
AppStateManagerImploperator= (AppStateManagerImpl &&) noexcept=delete
 
void atPrepare (OnPrepare &&cb) override
 Execute. More...
 
void atLaunch (OnLaunch &&cb) override
 Execute. More...
 
void atShutdown (OnShutdown &&cb) override
 Execute. More...
 
void run () override
 Start application life cycle. More...
 
void shutdown () override
 Initiate shutting down (at any time) More...
 
State state () const override
 Get current stage. More...
 
- Public Member Functions inherited from kagome::application::AppStateManager
virtual ~AppStateManager ()=default
 
void registerHandlers (OnPrepare &&prepare_cb, OnLaunch &&launch_cb, OnShutdown &&shutdown_cb)
 Registration of all stages' handlers at the same time. More...
 
template<typename Controlled >
void takeControl (Controlled &entity)
 Registration special methods of object as handlers for stages of application life-cycle. More...
 

Protected Member Functions

void reset ()
 
void doPrepare () override
 
void doLaunch () override
 
void doShutdown () override
 

Static Private Member Functions

static void shuttingDownSignalsHandler (int)
 

Private Attributes

log::Logger logger_
 
std::atomic< Statestate_ = State::Init
 
std::recursive_mutex mutex_
 
std::mutex cv_mutex_
 
std::condition_variable cv_
 
std::queue< OnPrepareprepare_
 
std::queue< OnLaunchlaunch_
 
std::queue< OnShutdownshutdown_
 
std::atomic_bool shutdown_requested_ {false}
 

Static Private Attributes

static std::weak_ptr< AppStateManagerwp_to_myself
 

Additional Inherited Members

- Public Types inherited from kagome::application::AppStateManager
enum  State {
  State::Init, State::Prepare, State::ReadyToStart, State::Starting,
  State::Works, State::ShuttingDown, State::ReadyToStop
}
 
using OnPrepare = std::function< bool()>
 
using OnLaunch = std::function< bool()>
 
using OnShutdown = std::function< void()>
 

Detailed Description

Definition at line 20 of file app_state_manager_impl.hpp.

Constructor & Destructor Documentation

kagome::application::AppStateManagerImpl::AppStateManagerImpl ( )

Definition at line 21 of file app_state_manager_impl.cpp.

kagome::application::AppStateManagerImpl::AppStateManagerImpl ( const AppStateManagerImpl )
delete
kagome::application::AppStateManagerImpl::AppStateManagerImpl ( AppStateManagerImpl &&  )
deletenoexcept
kagome::application::AppStateManagerImpl::~AppStateManagerImpl ( )
override

Definition at line 38 of file app_state_manager_impl.cpp.

Member Function Documentation

void kagome::application::AppStateManagerImpl::atLaunch ( OnLaunch &&  cb)
overridevirtual

Execute.

Parameters
cbimmediately before start application
cb

Implements kagome::application::AppStateManager.

Definition at line 70 of file app_state_manager_impl.cpp.

void kagome::application::AppStateManagerImpl::atPrepare ( OnPrepare &&  cb)
overridevirtual

Execute.

Parameters
cbat stage of prepare application
cb

Implements kagome::application::AppStateManager.

Definition at line 62 of file app_state_manager_impl.cpp.

void kagome::application::AppStateManagerImpl::atShutdown ( OnShutdown &&  cb)
overridevirtual

Execute.

Parameters
cbat stage of shutting down application
cb

Implements kagome::application::AppStateManager.

Definition at line 78 of file app_state_manager_impl.cpp.

void kagome::application::AppStateManagerImpl::doLaunch ( )
overrideprotectedvirtual

Implements kagome::application::AppStateManager.

Definition at line 111 of file app_state_manager_impl.cpp.

void kagome::application::AppStateManagerImpl::doPrepare ( )
overrideprotectedvirtual

Implements kagome::application::AppStateManager.

Definition at line 86 of file app_state_manager_impl.cpp.

void kagome::application::AppStateManagerImpl::doShutdown ( )
overrideprotectedvirtual

Implements kagome::application::AppStateManager.

Definition at line 136 of file app_state_manager_impl.cpp.

AppStateManagerImpl& kagome::application::AppStateManagerImpl::operator= ( AppStateManagerImpl const &  )
delete
AppStateManagerImpl& kagome::application::AppStateManagerImpl::operator= ( AppStateManagerImpl &&  )
deletenoexcept
void kagome::application::AppStateManagerImpl::reset ( )
protected

Definition at line 53 of file app_state_manager_impl.cpp.

void kagome::application::AppStateManagerImpl::run ( )
overridevirtual

Start application life cycle.

Implements kagome::application::AppStateManager.

Definition at line 157 of file app_state_manager_impl.cpp.

void kagome::application::AppStateManagerImpl::shutdown ( )
overridevirtual

Initiate shutting down (at any time)

Implements kagome::application::AppStateManager.

Definition at line 176 of file app_state_manager_impl.cpp.

void kagome::application::AppStateManagerImpl::shuttingDownSignalsHandler ( int  )
staticprivate

Definition at line 15 of file app_state_manager_impl.cpp.

State kagome::application::AppStateManagerImpl::state ( ) const
inlineoverridevirtual

Get current stage.

Implements kagome::application::AppStateManager.

Definition at line 38 of file app_state_manager_impl.hpp.

Member Data Documentation

std::condition_variable kagome::application::AppStateManagerImpl::cv_
private

Definition at line 60 of file app_state_manager_impl.hpp.

std::mutex kagome::application::AppStateManagerImpl::cv_mutex_
private

Definition at line 59 of file app_state_manager_impl.hpp.

std::queue<OnLaunch> kagome::application::AppStateManagerImpl::launch_
private

Definition at line 63 of file app_state_manager_impl.hpp.

log::Logger kagome::application::AppStateManagerImpl::logger_
private

Definition at line 53 of file app_state_manager_impl.hpp.

std::recursive_mutex kagome::application::AppStateManagerImpl::mutex_
private

Definition at line 57 of file app_state_manager_impl.hpp.

std::queue<OnPrepare> kagome::application::AppStateManagerImpl::prepare_
private

Definition at line 62 of file app_state_manager_impl.hpp.

std::queue<OnShutdown> kagome::application::AppStateManagerImpl::shutdown_
private

Definition at line 64 of file app_state_manager_impl.hpp.

std::atomic_bool kagome::application::AppStateManagerImpl::shutdown_requested_ {false}
private

Definition at line 66 of file app_state_manager_impl.hpp.

std::atomic<State> kagome::application::AppStateManagerImpl::state_ = State::Init
private

Definition at line 55 of file app_state_manager_impl.hpp.

std::weak_ptr< AppStateManager > kagome::application::AppStateManagerImpl::wp_to_myself
staticprivate

Definition at line 50 of file app_state_manager_impl.hpp.


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