libfoedus-core
FOEDUS Core Library
foedus::DefaultInitializable Class Referenceabstract

Typical implementation of Initializable as a skeleton base class. More...

Detailed Description

Typical implementation of Initializable as a skeleton base class.

The implementation of Initializable can either derive from this class or define by its own (eg. to avoid diamond inheritance). If it chooses to use this class, it must define "ErrorStack initialize_once()", and "ErrorStack uninitialize_once()".

Defined methods
This class declares and defines the following methods:
Declared methods
This class declares the following methods, which the class has to define in cpp:
  • initialize_one()/uninitialize_once().
Disabled methods
This class disables the following methods, which don't fly with Initializable:
  • default copy constructor.
  • default copy assignment operator.

Definition at line 157 of file initializable.hpp.

#include <initializable.hpp>

Inheritance diagram for foedus::DefaultInitializable:
Collaboration diagram for foedus::DefaultInitializable:

Public Member Functions

 DefaultInitializable ()
 
virtual ~DefaultInitializable ()
 
 DefaultInitializable (const DefaultInitializable &)=delete
 
DefaultInitializableoperator= (const DefaultInitializable &)=delete
 
ErrorStack initialize () override final
 Typical implementation of Initializable::initialize() that provides initialize-once semantics. More...
 
ErrorStack uninitialize () override final
 Typical implementation of Initializable::uninitialize() that provides uninitialize-once semantics. More...
 
bool is_initialized () const override final
 Returns whether the object has been already initialized or not. More...
 
virtual ErrorStack initialize_once ()=0
 
virtual ErrorStack uninitialize_once ()=0
 
- Public Member Functions inherited from foedus::Initializable
virtual ~Initializable ()
 

Constructor & Destructor Documentation

foedus::DefaultInitializable::DefaultInitializable ( )
inline

Definition at line 159 of file initializable.hpp.

159 : initialized_(false) {}
virtual foedus::DefaultInitializable::~DefaultInitializable ( )
inlinevirtual

Definition at line 160 of file initializable.hpp.

160 {}
foedus::DefaultInitializable::DefaultInitializable ( const DefaultInitializable )
delete

Member Function Documentation

ErrorStack foedus::DefaultInitializable::initialize ( )
inlinefinaloverridevirtual

Typical implementation of Initializable::initialize() that provides initialize-once semantics.

Implements foedus::Initializable.

Definition at line 169 of file initializable.hpp.

References CHECK_ERROR, ERROR_STACK, initialize_once(), foedus::ErrorStack::is_error(), is_initialized(), foedus::kErrorCodeAlreadyInitialized, foedus::kRetOk, and uninitialize_once().

Referenced by foedus::storage::array::ArrayComposer::compose(), foedus::storage::hash::HashComposer::compose(), foedus::storage::masstree::MasstreeComposer::compose(), foedus::storage::hash::HashStoragePimpl::debugout_single_thread(), foedus::storage::masstree::MasstreeStoragePimpl::debugout_single_thread(), foedus::snapshot::SnapshotManager::initialize(), foedus::savepoint::SavepointManager::initialize(), foedus::proc::ProcManager::initialize(), foedus::xct::XctManager::initialize(), foedus::log::LogManager::initialize(), foedus::restart::RestartManager::initialize(), foedus::storage::StorageManager::initialize(), foedus::thread::Thread::initialize(), foedus::soc::SocManager::initialize(), foedus::thread::ThreadPool::initialize(), foedus::Engine::initialize(), foedus::memory::PagePool::initialize(), foedus::thread::ThreadPoolPimpl::initialize_once(), foedus::memory::EngineMemory::initialize_once(), foedus::log::LogManagerPimpl::initialize_once(), foedus::thread::ThreadPimpl::initialize_once(), foedus::snapshot::SnapshotManagerPimpl::initialize_once(), foedus::snapshot::LogReducer::initialize_once(), foedus::storage::array::ArrayStoragePimpl::load(), foedus::storage::masstree::MasstreeStoragePimpl::load(), foedus::storage::hash::HashStoragePimpl::load(), and foedus::storage::StorageManagerPimpl::reinitialize_for_recovered_snapshot().

169  {
170  if (is_initialized()) {
172  }
173  ErrorStack init_error = initialize_once();
174  if (init_error.is_error()) {
175  // if error happes in the middle of initialization, we release resources we acquired.
177  return init_error;
178  }
179  initialized_ = true;
180  return kRetOk;
181  }
#define ERROR_STACK(e)
Instantiates ErrorStack with the given foedus::error_code, creating an error stack with the current f...
virtual ErrorStack uninitialize_once()=0
0x0003 : "GENERAL: Already initialized" .
Definition: error_code.hpp:107
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
const ErrorStack kRetOk
Normal return value for no-error case.
virtual ErrorStack initialize_once()=0
bool is_initialized() const override final
Returns whether the object has been already initialized or not.

Here is the call graph for this function:

Here is the caller graph for this function:

bool foedus::DefaultInitializable::is_initialized ( ) const
inlinefinaloverridevirtual
DefaultInitializable& foedus::DefaultInitializable::operator= ( const DefaultInitializable )
delete
ErrorStack foedus::DefaultInitializable::uninitialize ( )
inlinefinaloverridevirtual

Typical implementation of Initializable::uninitialize() that provides uninitialize-once semantics.

Implements foedus::Initializable.

Definition at line 187 of file initializable.hpp.

References CHECK_ERROR, is_initialized(), foedus::kRetOk, and uninitialize_once().

Referenced by foedus::storage::array::ArrayComposer::compose(), foedus::storage::hash::HashComposer::compose(), foedus::storage::masstree::MasstreeComposer::compose(), foedus::storage::hash::HashStoragePimpl::debugout_single_thread(), foedus::storage::masstree::MasstreeStoragePimpl::debugout_single_thread(), foedus::storage::array::ArrayStoragePimpl::load(), foedus::storage::masstree::MasstreeStoragePimpl::load(), foedus::storage::hash::HashStoragePimpl::load(), foedus::storage::StorageManagerPimpl::reinitialize_for_recovered_snapshot(), foedus::snapshot::SnapshotManager::uninitialize(), foedus::savepoint::SavepointManager::uninitialize(), foedus::proc::ProcManager::uninitialize(), foedus::xct::XctManager::uninitialize(), foedus::log::LogManager::uninitialize(), foedus::restart::RestartManager::uninitialize(), foedus::storage::StorageManager::uninitialize(), foedus::thread::Thread::uninitialize(), foedus::soc::SocManager::uninitialize(), foedus::thread::ThreadPool::uninitialize(), foedus::Engine::uninitialize(), foedus::memory::PagePool::uninitialize(), foedus::thread::ThreadPoolPimpl::uninitialize_once(), foedus::memory::EngineMemory::uninitialize_once(), foedus::log::LogManagerPimpl::uninitialize_once(), foedus::thread::ThreadPimpl::uninitialize_once(), foedus::snapshot::SnapshotManagerPimpl::uninitialize_once(), and foedus::snapshot::LogReducer::uninitialize_once().

187  {
188  if (!is_initialized()) {
189  return kRetOk;
190  }
192  initialized_ = false;
193  return kRetOk;
194  }
virtual ErrorStack uninitialize_once()=0
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
const ErrorStack kRetOk
Normal return value for no-error case.
bool is_initialized() const override final
Returns whether the object has been already initialized or not.

Here is the call graph for this function:

Here is the caller graph for this function:


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