MySQL 9.1.0
Source Code Documentation
mysql_harness::ProcessStateComponent Class Reference

manages the state of the process. More...

#include <process_state_component.h>

Public Types

using key_type = std::string
 
using on_shutdown_request_callback = std::function< void(ShutdownPending::Reason reason, const std::string &msg)>
 

Public Member Functions

 ProcessStateComponent (ProcessStateComponent const &)=delete
 
void operator= (ProcessStateComponent const &)=delete
 
 ProcessStateComponent (ProcessStateComponent &&)=delete
 
void operator= (ProcessStateComponent &&)=delete
 
void clear ()
 
void request_application_shutdown (const ShutdownPending::Reason reason=ShutdownPending::Reason::REQUESTED, const std::string &msg={})
 request application shutdown. More...
 
void register_on_shutdown_request_callback (on_shutdown_request_callback callback)
 register a callback that will get exectued whenever the component gets the shutdown request More...
 
WaitableMonitor< ShutdownPending > & shutdown_pending ()
 pending shutdown state. More...
 

Static Public Member Functions

static ProcessStateComponentget_instance ()
 

Private Member Functions

 ProcessStateComponent ()=default
 

Private Attributes

WaitableMonitor< ShutdownPendingshutdown_pending_ {{}}
 
std::vector< on_shutdown_request_callbackon_shutdown_request_callbacks_
 

Detailed Description

manages the state of the process.

allows to shutdown the current process in a

  • thread safe
  • waitable

way.

To be used

  • by the signal-handler to mark the process for shutdown,
  • and by the Loader to wait for a shutdown to happen.

Member Typedef Documentation

◆ key_type

◆ on_shutdown_request_callback

using mysql_harness::ProcessStateComponent::on_shutdown_request_callback = std::function<void( ShutdownPending::Reason reason, const std::string &msg)>

Constructor & Destructor Documentation

◆ ProcessStateComponent() [1/3]

mysql_harness::ProcessStateComponent::ProcessStateComponent ( ProcessStateComponent const &  )
delete

◆ ProcessStateComponent() [2/3]

mysql_harness::ProcessStateComponent::ProcessStateComponent ( ProcessStateComponent &&  )
delete

◆ ProcessStateComponent() [3/3]

mysql_harness::ProcessStateComponent::ProcessStateComponent ( )
privatedefault

Member Function Documentation

◆ clear()

void mysql_harness::ProcessStateComponent::clear ( )

◆ get_instance()

ProcessStateComponent & mysql_harness::ProcessStateComponent::get_instance ( )
static

◆ operator=() [1/2]

void mysql_harness::ProcessStateComponent::operator= ( ProcessStateComponent &&  )
delete

◆ operator=() [2/2]

void mysql_harness::ProcessStateComponent::operator= ( ProcessStateComponent const &  )
delete

◆ register_on_shutdown_request_callback()

void mysql_harness::ProcessStateComponent::register_on_shutdown_request_callback ( on_shutdown_request_callback  callback)
inline

register a callback that will get exectued whenever the component gets the shutdown request

Parameters
callbackcallback to execute when the shutdown is requested

◆ request_application_shutdown()

void mysql_harness::ProcessStateComponent::request_application_shutdown ( const ShutdownPending::Reason  reason = ShutdownPending::Reason::REQUESTED,
const std::string &  msg = {} 
)

request application shutdown.

Parameters
reasonreason for the shutdown
msghuman readable reason of the shutdown
Exceptions
std::system_errorsame as std::unique_lock::lock does
std::system_errorsame as std::unique_lock::lock does

◆ shutdown_pending()

WaitableMonitor< ShutdownPending > & mysql_harness::ProcessStateComponent::shutdown_pending ( )
inline

pending shutdown state.

  • synchronized
  • waitable

Member Data Documentation

◆ on_shutdown_request_callbacks_

std::vector<on_shutdown_request_callback> mysql_harness::ProcessStateComponent::on_shutdown_request_callbacks_
private

◆ shutdown_pending_

WaitableMonitor<ShutdownPending> mysql_harness::ProcessStateComponent::shutdown_pending_ {{}}
private

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