libfoedus-core
FOEDUS Core Library
foedus::proc::ProcManager Class Referencefinal

Procedure manager, which maintains the list of system/user procedures. More...

Detailed Description

Procedure manager, which maintains the list of system/user procedures.

Definition at line 35 of file proc_manager.hpp.

#include <proc_manager.hpp>

Inheritance diagram for foedus::proc::ProcManager:
Collaboration diagram for foedus::proc::ProcManager:

Public Member Functions

 ProcManager (Engine *engine)
 
 ~ProcManager ()
 
 ProcManager ()=delete
 
 ProcManager (const ProcManager &)=delete
 
ProcManageroperator= (const ProcManager &)=delete
 
ErrorStack initialize () override
 Acquires resources in this object, usually called right after constructor. More...
 
bool is_initialized () const override
 Returns whether the object has been already initialized or not. More...
 
ErrorStack uninitialize () override
 An idempotent method to release all resources of this object, if any. More...
 
ErrorStack get_proc (const ProcName &name, Proc *out)
 Returns the function pointer of the specified procedure. More...
 
ErrorStack pre_register (const ProcAndName &proc_and_name)
 Pre-register a function pointer as a user procedure so that all SOCs will have it when they are forked. More...
 
ErrorStack pre_register (const ProcName &name, Proc proc)
 Just a synonym. More...
 
const std::vector< ProcAndName > & get_pre_registered_procedures () const
 Returns procedures given to pre_register() More...
 
ErrorStack local_register (const ProcAndName &proc_and_name)
 Register a function pointer as a user procedure in the current SOC. More...
 
ErrorStack emulated_register (const ProcAndName &proc_and_name)
 Register a function pointer as a user procedure in all SOCs, assuming that child SOCs are of kChildEmulated type. More...
 
std::string describe_registered_procs () const
 For debug uses only. More...
 
- Public Member Functions inherited from foedus::Initializable
virtual ~Initializable ()
 

Constructor & Destructor Documentation

foedus::proc::ProcManager::ProcManager ( Engine engine)
explicit

Definition at line 28 of file proc_manager.cpp.

28  : pimpl_(nullptr) {
29  pimpl_ = new ProcManagerPimpl(engine);
30 }
foedus::proc::ProcManager::~ProcManager ( )

Definition at line 31 of file proc_manager.cpp.

31  {
32  delete pimpl_;
33  pimpl_ = nullptr;
34 }
foedus::proc::ProcManager::ProcManager ( )
delete
foedus::proc::ProcManager::ProcManager ( const ProcManager )
delete

Member Function Documentation

std::string foedus::proc::ProcManager::describe_registered_procs ( ) const

For debug uses only.

Returns a summary of procedures registered in this engine

Definition at line 57 of file proc_manager.cpp.

References foedus::proc::ProcManagerPimpl::describe_registered_procs().

Referenced by foedus::soc::SocManagerPimpl::child_main_common().

57  {
58  return pimpl_->describe_registered_procs();
59 }
std::string describe_registered_procs() const

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorStack foedus::proc::ProcManager::emulated_register ( const ProcAndName proc_and_name)

Register a function pointer as a user procedure in all SOCs, assuming that child SOCs are of kChildEmulated type.

Precondition
Engine is initialized.
Child SOCs are of kChildEmulated type.

This can be used any time after the initialization and also takes effect in all SOCs. However, this can be used only with kChildEmulated SOCs. Most testcases and small programs that do not need high scalability can use this.

Definition at line 50 of file proc_manager.cpp.

References foedus::proc::ProcManagerPimpl::emulated_register().

50  {
51  return pimpl_->emulated_register(proc_and_name);
52 }
ErrorStack emulated_register(const ProcAndName &proc_and_name)

Here is the call graph for this function:

const std::vector< ProcAndName > & foedus::proc::ProcManager::get_pre_registered_procedures ( ) const

Returns procedures given to pre_register()

Definition at line 54 of file proc_manager.cpp.

References foedus::proc::ProcManagerPimpl::pre_registered_procs_.

Referenced by foedus::soc::SocManagerPimpl::emulated_child_main(), and foedus::soc::SocManagerPimpl::forked_child_main().

54  {
55  return pimpl_->pre_registered_procs_;
56 }
std::vector< ProcAndName > pre_registered_procs_

Here is the caller graph for this function:

ErrorStack foedus::proc::ProcManager::get_proc ( const ProcName name,
Proc out 
)

Returns the function pointer of the specified procedure.

Parameters
[in]nameName of the procedure that has been registered via one of the following methods
[out]outFunction pointer of the procedure.
Returns
Error if the given procedure name is not found.

Definition at line 40 of file proc_manager.cpp.

References foedus::proc::ProcManagerPimpl::get_proc().

Referenced by foedus::thread::ThreadPimpl::handle_tasks().

40  {
41  return pimpl_->get_proc(name, out);
42 }
ErrorStack get_proc(const ProcName &name, Proc *out)

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorStack foedus::proc::ProcManager::initialize ( )
overridevirtual

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.

Implements foedus::Initializable.

Definition at line 36 of file proc_manager.cpp.

References foedus::DefaultInitializable::initialize().

36 { return pimpl_->initialize(); }
ErrorStack initialize() override final
Typical implementation of Initializable::initialize() that provides initialize-once semantics...

Here is the call graph for this function:

bool foedus::proc::ProcManager::is_initialized ( ) const
overridevirtual

Returns whether the object has been already initialized or not.

Implements foedus::Initializable.

Definition at line 37 of file proc_manager.cpp.

References foedus::DefaultInitializable::is_initialized().

37 { return pimpl_->is_initialized(); }
bool is_initialized() const override final
Returns whether the object has been already initialized or not.

Here is the call graph for this function:

ErrorStack foedus::proc::ProcManager::local_register ( const ProcAndName proc_and_name)

Register a function pointer as a user procedure in the current SOC.

Precondition
Engine is initialized.
This engine is an SOC engine (child engine), not the master.

This can be used any time after the initialization, but it takes effect only in the current SOC. Function pointers cannot be shared with other processes.

Definition at line 47 of file proc_manager.cpp.

References foedus::proc::ProcManagerPimpl::local_register().

Referenced by foedus::soc::SocManagerPimpl::child_main_common().

47  {
48  return pimpl_->local_register(proc_and_name);
49 }
ErrorStack local_register(const ProcAndName &proc_and_name)

Here is the call graph for this function:

Here is the caller graph for this function:

ProcManager& foedus::proc::ProcManager::operator= ( const ProcManager )
delete
ErrorStack foedus::proc::ProcManager::pre_register ( const ProcAndName proc_and_name)

Pre-register a function pointer as a user procedure so that all SOCs will have it when they are forked.

Precondition
Engine's initialize() is NOT yet called because this is a pre-registration.
Child SOC types are either kChildEmulated or kChildForked.
This is a master engine. (if this is a child SOC engine, pre-register is too late)

This can be used only for kChildEmulated or kChildForked because function pointers can be shared only when the function pointers are finalized before the fork, or in the same process. So, once Engine is initialized, this method always fails.

Definition at line 44 of file proc_manager.cpp.

References foedus::proc::ProcManagerPimpl::pre_register().

Referenced by pre_register().

44  {
45  return pimpl_->pre_register(proc_and_name);
46 }
ErrorStack pre_register(const ProcAndName &proc_and_name)

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorStack foedus::proc::ProcManager::pre_register ( const ProcName name,
Proc  proc 
)
inline

Just a synonym.

Definition at line 70 of file proc_manager.hpp.

References pre_register().

70  {
71  return pre_register(ProcAndName(name, proc));
72  }
std::pair< ProcName, Proc > ProcAndName
Just a std::pair.
Definition: proc_id.hpp:119
ErrorStack pre_register(const ProcAndName &proc_and_name)
Pre-register a function pointer as a user procedure so that all SOCs will have it when they are forke...

Here is the call graph for this function:

ErrorStack foedus::proc::ProcManager::uninitialize ( )
overridevirtual

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.

Implements foedus::Initializable.

Definition at line 38 of file proc_manager.cpp.

References foedus::DefaultInitializable::uninitialize().

38 { return pimpl_->uninitialize(); }
ErrorStack uninitialize() override final
Typical implementation of Initializable::uninitialize() that provides uninitialize-once semantics...

Here is the call graph for this function:


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