Thrill  0.1
singleton< InstanceType, destroy_on_exit > Class Template Reference

Detailed Description

template<typename InstanceType, bool destroy_on_exit = true>
class foxxll::singleton< InstanceType, destroy_on_exit >

Definition at line 25 of file singleton.hpp.

+ Inheritance diagram for singleton< InstanceType, destroy_on_exit >:

#include <singleton.hpp>

Public Types

using instance_pointer = instance_type *
 
using instance_type = InstanceType
 
using volatile_instance_pointer = volatile instance_pointer
 

Public Member Functions

 singleton ()=default
 
 singleton (const singleton &)=delete
 non-copyable: delete copy-constructor More...
 
singletonoperator= (const singleton &)=delete
 non-copyable: delete assignment operator More...
 

Static Public Member Functions

template<typename SubInstanceType >
static instance_pointer create_instance ()
 create instance of SubInstanceType and move into singleton More...
 
static void destroy_instance ()
 destroy singleton and mark as invalid More...
 
static instance_pointer get_instance ()
 return instance or create base instance if empty More...
 
static instance_typeget_ref ()
 

Static Private Attributes

static volatile_instance_pointer instance_ = nullptr
 singleton object instance More...
 
static std::mutex singleton_mutex_
 mutex to protect instance_ More...
 

Member Typedef Documentation

◆ instance_pointer

Definition at line 29 of file singleton.hpp.

◆ instance_type

using instance_type = InstanceType

Definition at line 28 of file singleton.hpp.

◆ volatile_instance_pointer

Definition at line 30 of file singleton.hpp.

Constructor & Destructor Documentation

◆ singleton() [1/2]

singleton ( )
default

◆ singleton() [2/2]

singleton ( const singleton< InstanceType, destroy_on_exit > &  )
delete

non-copyable: delete copy-constructor

Member Function Documentation

◆ create_instance()

singleton< InstanceType, destroy_on_exit >::instance_pointer create_instance ( )
static

create instance of SubInstanceType and move into singleton

Definition at line 75 of file singleton.hpp.

Referenced by singleton< disk_queues >::get_ref().

◆ destroy_instance()

void destroy_instance ( )
static

destroy singleton and mark as invalid

Definition at line 87 of file singleton.hpp.

Referenced by singleton< disk_queues >::create_instance(), and singleton< disk_queues >::get_ref().

◆ get_instance()

static instance_pointer get_instance ( )
inlinestatic

return instance or create base instance if empty

Definition at line 41 of file singleton.hpp.

◆ get_ref()

static instance_type& get_ref ( )
inlinestatic

Definition at line 49 of file singleton.hpp.

◆ operator=()

singleton& operator= ( const singleton< InstanceType, destroy_on_exit > &  )
delete

non-copyable: delete assignment operator

Member Data Documentation

◆ instance_

singleton< InstanceType, destroy_on_exit >::volatile_instance_pointer instance_ = nullptr
staticprivate

◆ singleton_mutex_

std::mutex singleton_mutex_
staticprivate

mutex to protect instance_

Definition at line 69 of file singleton.hpp.

Referenced by singleton< disk_queues >::create_instance(), and singleton< disk_queues >::destroy_instance().


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