libfoedus-core
FOEDUS Core Library
foedus::thread::ThreadGroup Class Referencefinal

Represents a group of pre-allocated threads running in one NUMA node. More...

Detailed Description

Represents a group of pre-allocated threads running in one NUMA node.

Detailed description of this class.

Definition at line 38 of file thread_group.hpp.

#include <thread_group.hpp>

Inheritance diagram for foedus::thread::ThreadGroup:
Collaboration diagram for foedus::thread::ThreadGroup:

Public Member Functions

 ThreadGroup ()=delete
 
 ThreadGroup (Engine *engine, ThreadGroupId group_id)
 
 ~ThreadGroup ()
 
ErrorStack initialize_once () override
 
ErrorStack uninitialize_once () override
 
ThreadGroupId get_group_id () const
 
memory::NumaNodeMemoryget_node_memory () const
 
Threadget_thread (ThreadLocalOrdinal ordinal) const
 Returns Thread object for the given ordinal in this group. More...
 
- Public Member Functions inherited from foedus::DefaultInitializable
 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...
 
- Public Member Functions inherited from foedus::Initializable
virtual ~Initializable ()
 

Friends

std::ostream & operator<< (std::ostream &o, const ThreadGroup &v)
 

Constructor & Destructor Documentation

foedus::thread::ThreadGroup::ThreadGroup ( )
delete
foedus::thread::ThreadGroup::ThreadGroup ( Engine engine,
ThreadGroupId  group_id 
)

Definition at line 32 of file thread_group.cpp.

33  : engine_(engine), group_id_(group_id) {
34 }
foedus::thread::ThreadGroup::~ThreadGroup ( )

Definition at line 35 of file thread_group.cpp.

35  {
36 }

Member Function Documentation

ThreadGroupId foedus::thread::ThreadGroup::get_group_id ( ) const
inline

Definition at line 46 of file thread_group.hpp.

46 { return group_id_; }
memory::NumaNodeMemory* foedus::thread::ThreadGroup::get_node_memory ( ) const
inline

Definition at line 47 of file thread_group.hpp.

47 { return node_memory_; }
Thread* foedus::thread::ThreadGroup::get_thread ( ThreadLocalOrdinal  ordinal) const
inline

Returns Thread object for the given ordinal in this group.

Definition at line 50 of file thread_group.hpp.

Referenced by foedus::log::Logger::initialize_once().

50 { return threads_[ordinal]; }

Here is the caller graph for this function:

ErrorStack foedus::thread::ThreadGroup::initialize_once ( )
overridevirtual

Implements foedus::DefaultInitializable.

Definition at line 38 of file thread_group.cpp.

References CHECK_ERROR, foedus::thread::compose_thread_id(), foedus::memory::EngineMemory::get_local_memory(), foedus::Engine::get_memory_manager(), foedus::Engine::get_options(), foedus::kRetOk, foedus::EngineOptions::thread_, foedus::thread::ThreadOptions::thread_count_per_group_, and foedus::thread::to_global_ordinal().

38  {
39  node_memory_ = engine_->get_memory_manager()->get_local_memory();
41  for (ThreadLocalOrdinal ordinal = 0; ordinal < count; ++ordinal) {
42  ThreadId id = compose_thread_id(group_id_, ordinal);
43  ThreadGlobalOrdinal global_ordinal = to_global_ordinal(id, count);
44  threads_.push_back(new Thread(engine_, id, global_ordinal));
45  CHECK_ERROR(threads_.back()->initialize());
46  }
47  return kRetOk;
48 }
uint8_t ThreadLocalOrdinal
Typedef for a local ID of Thread (core), which is NOT unique across NUMA nodes.
Definition: thread_id.hpp:58
const EngineOptions & get_options() const
Definition: engine.cpp:39
ThreadLocalOrdinal thread_count_per_group_
Number of Thread in each ThreadGroup.
ThreadId compose_thread_id(ThreadGroupId node, ThreadLocalOrdinal local_core)
Returns a globally unique ID of Thread (core) for the given node and ordinal in the node...
Definition: thread_id.hpp:123
uint16_t ThreadGlobalOrdinal
Typedef for a globally and contiguously numbered ID of thread.
Definition: thread_id.hpp:98
thread::ThreadOptions thread_
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
NumaNodeMemory * get_local_memory() const
uint16_t ThreadId
Typedef for a global ID of Thread (core), which is unique across NUMA nodes.
Definition: thread_id.hpp:80
const ErrorStack kRetOk
Normal return value for no-error case.
ThreadGlobalOrdinal to_global_ordinal(ThreadId thread_id, uint8_t threads_per_nodes)
Calculate ThreadGlobalOrdinal from ThreadId.
Definition: thread_id.hpp:147
memory::EngineMemory * get_memory_manager() const
See Memory Manager.
Definition: engine.cpp:50

Here is the call graph for this function:

ErrorStack foedus::thread::ThreadGroup::uninitialize_once ( )
overridevirtual

Implements foedus::DefaultInitializable.

Definition at line 50 of file thread_group.cpp.

References SUMMARIZE_ERROR_BATCH, and foedus::ErrorStackBatch::uninitialize_and_delete_all().

50  {
51  ErrorStackBatch batch;
52  batch.uninitialize_and_delete_all(&threads_);
53  node_memory_ = nullptr;
54  return SUMMARIZE_ERROR_BATCH(batch);
55 }
#define SUMMARIZE_ERROR_BATCH(x)
This macro calls ErrorStackBatch::summarize() with automatically provided parameters.

Here is the call graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const ThreadGroup v 
)
friend

Definition at line 57 of file thread_group.cpp.

57  {
58  o << "<ThreadGroup>";
59  o << "<group_id_>" << static_cast<int>(v.group_id_) << "</group_id_>";
60  o << "<threads_>";
61  for (Thread* child_thread : v.threads_) {
62  o << *child_thread;
63  }
64  o << "</threads_>";
65  o << "</ThreadGroup>";
66  return o;
67 }

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