libfoedus-core
FOEDUS Core Library
thread_pool_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_THREAD_THREAD_POOL_PIMPL_HPP_
19 #define FOEDUS_THREAD_THREAD_POOL_PIMPL_HPP_
20 #include <iosfwd>
21 #include <vector>
22 
23 #include "foedus/fwd.hpp"
24 #include "foedus/initializable.hpp"
25 #include "foedus/memory/fwd.hpp"
26 #include "foedus/thread/fwd.hpp"
30 
31 namespace foedus {
32 namespace thread {
33 
41 class ThreadPoolPimpl final : public DefaultInitializable {
42  public:
43  ThreadPoolPimpl() = delete;
44  explicit ThreadPoolPimpl(Engine* engine) : engine_(engine), local_group_(nullptr) {}
45  ErrorStack initialize_once() override;
46  ErrorStack uninitialize_once() override;
47 
48  bool impersonate(
49  const proc::ProcName& proc_name,
50  const void* task_input,
51  uint64_t task_input_size,
52  ImpersonateSession *session);
54  ThreadGroupId node,
55  const proc::ProcName& proc_name,
56  const void* task_input,
57  uint64_t task_input_size,
58  ImpersonateSession *session);
60  ThreadId core,
61  const proc::ProcName& proc_name,
62  const void* task_input,
63  uint64_t task_input_size,
64  ImpersonateSession *session);
65 
66  ThreadGroupRef* get_group(ThreadGroupId numa_node) { return &groups_[numa_node]; }
69 
74 
75  friend std::ostream& operator<<(std::ostream& o, const ThreadPoolPimpl& v);
76 
77  Engine* const engine_;
78 
84 
89  std::vector<ThreadGroupRef> groups_;
90 };
91 
93  ThreadGroupId numa_node = decompose_numa_node(id);
95  return groups_[numa_node].get_thread_ref(core_ordinal);
96 }
97 
98 } // namespace thread
99 } // namespace foedus
100 #endif // FOEDUS_THREAD_THREAD_POOL_PIMPL_HPP_
ThreadGroup * local_group_
Thread group of the local SOC engine.
Pimpl object of ThreadPool.
uint8_t ThreadLocalOrdinal
Typedef for a local ID of Thread (core), which is NOT unique across NUMA nodes.
Definition: thread_id.hpp:58
A view of Thread group object for other SOCs and master engine.
Definition: thread_ref.hpp:106
ThreadRef get_thread_ref(ThreadId id) __attribute__((always_inline))
For better performance, but for some reason this method causes an issue in MCS lock.
ThreadGroup * get_local_group() const
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
Typedefs of ID types used in thread package.
ThreadLocalOrdinal decompose_numa_local_ordinal(ThreadId global_id)
Extracts local ordinal from the given globally unique ID of Thread (core).
Definition: thread_id.hpp:139
Forward declarations of classes in root package.
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
ThreadGroupRef * get_group(ThreadGroupId numa_node)
Typical implementation of Initializable as a skeleton base class.
bool impersonate(const proc::ProcName &proc_name, const void *task_input, uint64_t task_input_size, ImpersonateSession *session)
A user session running on an impersonated thread.
friend std::ostream & operator<<(std::ostream &o, const ThreadPoolPimpl &v)
Represents a group of pre-allocated threads running in one NUMA node.
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
A view of Thread object for other SOCs and master engine.
Definition: thread_ref.hpp:39
ThreadRef * get_thread(ThreadId id)
ThreadGroupId decompose_numa_node(ThreadId global_id)
Extracts NUMA node ID from the given globally unique ID of Thread (core).
Definition: thread_id.hpp:131
ErrorStack initialize_once() override
std::vector< ThreadGroupRef > groups_
List of all thread groups, one for each NUMA node in this engine.
Forward declarations of classes in memory package.
bool impersonate_on_numa_node(ThreadGroupId node, const proc::ProcName &proc_name, const void *task_input, uint64_t task_input_size, ImpersonateSession *session)
uint16_t ThreadId
Typedef for a global ID of Thread (core), which is unique across NUMA nodes.
Definition: thread_id.hpp:80
bool impersonate_on_numa_core(ThreadId core, const proc::ProcName &proc_name, const void *task_input, uint64_t task_input_size, ImpersonateSession *session)
ErrorStack uninitialize_once() override
Forward declarations of classes in thread package.
#define ALWAYS_INLINE
A function suffix to hint that the function should always be inlined.
Definition: compiler.hpp:106
uint8_t ThreadGroupId
Typedef for an ID of ThreadGroup (NUMA node).
Definition: thread_id.hpp:38