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

The pure-virtual interface to initialize/uninitialize non-trivial resources. More...

Detailed Description

The pure-virtual interface to initialize/uninitialize non-trivial resources.

Definition at line 99 of file initializable.hpp.

#include <initializable.hpp>

Inheritance diagram for foedus::Initializable:

Public Member Functions

virtual ~Initializable ()
 
virtual ErrorStack initialize ()=0
 Acquires resources in this object, usually called right after constructor. More...
 
virtual bool is_initialized () const =0
 Returns whether the object has been already initialized or not. More...
 
virtual ErrorStack uninitialize ()=0
 An idempotent method to release all resources of this object, if any. More...
 

Constructor & Destructor Documentation

virtual foedus::Initializable::~Initializable ( )
inlinevirtual

Definition at line 101 of file initializable.hpp.

101 {}

Member Function Documentation

virtual ErrorStack foedus::Initializable::initialize ( )
pure virtual

Acquires resources in this object, usually called right after constructor.

Precondition
is_initialized() == FALSE

If and only if the return value was not an error, is_initialized() will return TRUE. This method is usually not idempotent, but some implementation can choose to be. In that case, the implementation class should clarify that it's idempotent. This method is responsible for releasing all acquired resources when initialization fails. This method itself is NOT thread-safe. Do not call this in a racy situation.

Implemented in foedus::memory::PagePool, foedus::DefaultInitializable, foedus::Engine, foedus::thread::ThreadPool, foedus::soc::SocManager, foedus::thread::Thread, foedus::storage::StorageManager, foedus::log::LogManager, foedus::restart::RestartManager, foedus::proc::ProcManager, foedus::xct::XctManager, foedus::savepoint::SavepointManager, and foedus::snapshot::SnapshotManager.

virtual ErrorStack foedus::Initializable::uninitialize ( )
pure virtual

An idempotent method to release all resources of this object, if any.

After this method, is_initialized() will return FALSE. Whether this method encounters an error or not, the implementation should make the best effort to release as many resources as possible. In other words, Do not leak all resources because of one issue. This method itself is NOT thread-safe. Do not call this in a racy situation.

Attention
This method is NOT automatically called from the destructor. This is due to the fundamental limitation in C++. Explicitly call this method as soon as you are done, checking the returned value. You can also use UninitializeGuard to ameliorate the issue, but it's not perfect.
Returns
The error this method encounters, if any. In case there are multiple errors while uninitialization, the implementation should use ErrorStackBatch to produce a batched ErrorStack object.

Implemented in foedus::memory::PagePool, foedus::DefaultInitializable, foedus::Engine, foedus::thread::ThreadPool, foedus::soc::SocManager, foedus::thread::Thread, foedus::storage::StorageManager, foedus::log::LogManager, foedus::restart::RestartManager, foedus::proc::ProcManager, foedus::xct::XctManager, foedus::savepoint::SavepointManager, and foedus::snapshot::SnapshotManager.

Referenced by foedus::UninitializeGuard::~UninitializeGuard().

Here is the caller graph for this function:


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