libfoedus-core
FOEDUS Core Library
proc_manager_pimpl.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015, Hewlett-Packard Development Company, LP.
3  * This program is free software; you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the Free
5  * Software Foundation; either version 2 of the License, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11  * more details. You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  *
15  * HP designates this particular file as subject to the "Classpath" exception
16  * as provided by HP in the LICENSE.txt file that accompanied this code.
17  */
18 #ifndef FOEDUS_PROC_PROC_MANAGER_PIMPL_HPP_
19 #define FOEDUS_PROC_PROC_MANAGER_PIMPL_HPP_
20 
21 #include <string>
22 #include <vector>
23 
24 #include "foedus/fwd.hpp"
25 #include "foedus/initializable.hpp"
26 #include "foedus/proc/fwd.hpp"
27 #include "foedus/proc/proc_id.hpp"
30 
31 namespace foedus {
32 namespace proc {
37  // this is backed by shared memory. not instantiation. just reinterpret_cast.
38  ProcManagerControlBlock() = delete;
39  ~ProcManagerControlBlock() = delete;
40 
41  void initialize() {
42  lock_.initialize();
43  count_ = 0;
44  }
45  void uninitialize() {
47  }
48 
56 };
57 
65 class ProcManagerPimpl final : public DefaultInitializable {
66  public:
68  struct SharedData {
69  SharedData() : control_block_(nullptr), procs_(nullptr), name_sort_(nullptr) {}
75  };
76 
77  ProcManagerPimpl() = delete;
78  explicit ProcManagerPimpl(Engine* engine) : engine_(engine) {}
79 
80  ErrorStack initialize_once() override;
81  ErrorStack uninitialize_once() override;
82 
83  std::string describe_registered_procs() const;
84  ErrorStack get_proc(const ProcName& name, Proc* out);
85  ErrorStack pre_register(const ProcAndName& proc_and_name);
86  ErrorStack local_register(const ProcAndName& proc_and_name);
87  ErrorStack emulated_register(const ProcAndName& proc_and_name);
88  SharedData* get_local_data();
89  const SharedData* get_local_data() const;
90 
91  static LocalProcId find_by_name(const ProcName& name, SharedData* shared_data);
92  static LocalProcId insert(const ProcAndName& proc_and_name, SharedData* shared_data);
93 
94  Engine* const engine_;
95  std::vector< ProcAndName > pre_registered_procs_;
99  std::vector< SharedData > all_soc_procs_;
100 };
101 static_assert(
103  "ProcManagerControlBlock is too large.");
104 } // namespace proc
105 } // namespace foedus
106 #endif // FOEDUS_PROC_PROC_MANAGER_PIMPL_HPP_
ErrorStack uninitialize_once() override
LocalProcId * name_sort_
IDs sorted by name for quick lookup.
std::vector< SharedData > all_soc_procs_
Shared data of all SOCs.
ErrorStack local_register(const ProcAndName &proc_and_name)
void initialize(bool recursive=false)
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
static LocalProcId find_by_name(const ProcName &name, SharedData *shared_data)
Forward declarations of classes in root package.
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
soc::SharedMutex lock_
Mutex to protect data.
Typical implementation of Initializable as a skeleton base class.
A mutex that can be placed in shared memory and used from multiple processes.
ErrorStack initialize_once() override
ErrorStack pre_register(const ProcAndName &proc_and_name)
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
Typedefs of ID types used in procedure package.
std::string describe_registered_procs() const
std::pair< ProcName, Proc > ProcAndName
Just a std::pair.
Definition: proc_id.hpp:119
ErrorStack get_proc(const ProcName &name, Proc *out)
ErrorStack emulated_register(const ProcAndName &proc_and_name)
ProcAndName * procs_
The procedure list maintained in this module is an array of ProcName.
This small control block is used to synchronize the access to the array.
uint32_t LocalProcId
Represents a locally-unique ID of a procedure in one SOC.
Definition: proc_id.hpp:56
ErrorStack(* Proc)(const ProcArguments &args)
A function pointer of a user/system stored procedure.
Definition: proc_id.hpp:113
Pimpl object of ProcManager.
Forward declarations of classes in proc package.
static LocalProcId insert(const ProcAndName &proc_and_name, SharedData *shared_data)
std::vector< ProcAndName > pre_registered_procs_