Cbeam
|
Base class for controlling the lifecycle of all singleton
instances across different types.
More...
#include <singleton.hpp>
Public Member Functions | |
virtual | ~singleton_control ()=default |
Static Public Member Functions | |
static void | reset () |
Resets (shuts down) all stored singleton instances. | |
static void | set_operational () |
Ends the shut-down state and allows singletons to be created again. | |
Protected Member Functions | |
virtual void | release_instance ()=0 |
Releases the internal resource of the derived singleton. Called during a global reset. | |
Static Protected Attributes | |
static std::map< std::string, std::unique_ptr< singleton_control > > | _instances |
static std::mutex | _mutex |
static bool | _shutdown {false} |
Base class for controlling the lifecycle of all singleton
instances across different types.
singleton_control
allows a coordinated reset or shutdown of multiple resources that are each managed by singleton<T, ...>
. This is achieved by storing all instances in a static map and providing methods to reset or to set the operational state.
|
virtualdefault |
|
protectedpure virtual |
Releases the internal resource of the derived singleton. Called during a global reset.
Implemented in cbeam::lifecycle::singleton< T, Args >.
|
inlinestatic |
Resets (shuts down) all stored singleton instances.
After calling reset()
, new calls to singleton<T>::get(...)
will return nullptr
until set_operational()
is called. This is a global, collective approach for explicitly destroying all singletons and freeing their resources in a controlled manner.
|
inlinestatic |
Ends the shut-down state and allows singletons to be created again.
Particularly useful in test scenarios where you want to re-initialize singletons after a global teardown.
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inlinestaticprotected |