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

A view of Thread group object for other SOCs and master engine. More...

Detailed Description

A view of Thread group object for other SOCs and master engine.

Definition at line 106 of file thread_ref.hpp.

#include <thread_ref.hpp>

Public Member Functions

 ThreadGroupRef ()
 
 ThreadGroupRef (Engine *engine, ThreadGroupId group_id)
 
Engineget_engine () const
 
ThreadGroupId get_group_id () const
 
ThreadRefget_thread (ThreadLocalOrdinal ordinal)
 Returns Thread object for the given ordinal in this group. More...
 
ThreadRef get_thread_ref (ThreadLocalOrdinal ordinal) const
 Returns a copied instance. More...
 
Epoch get_min_in_commit_epoch () const
 Returns the oldest in-commit epoch of the threads in this group. More...
 

Friends

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

Constructor & Destructor Documentation

foedus::thread::ThreadGroupRef::ThreadGroupRef ( )

Definition at line 103 of file thread_ref.cpp.

103  : engine_(nullptr), group_id_(0) {
104 }
foedus::thread::ThreadGroupRef::ThreadGroupRef ( Engine engine,
ThreadGroupId  group_id 
)

Definition at line 106 of file thread_ref.cpp.

References foedus::thread::compose_thread_id(), foedus::Engine::get_options(), foedus::EngineOptions::thread_, and foedus::thread::ThreadOptions::thread_count_per_group_.

107  : engine_(engine), group_id_(group_id) {
108  uint16_t count = engine->get_options().thread_.thread_count_per_group_;
109  for (uint16_t i = 0; i < count; ++i) {
110  threads_.emplace_back(ThreadRef(engine, compose_thread_id(group_id, i)));
111  }
112 }
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

Here is the call graph for this function:

Member Function Documentation

Engine* foedus::thread::ThreadGroupRef::get_engine ( ) const
inline

Definition at line 111 of file thread_ref.hpp.

111 { return engine_; }
ThreadGroupId foedus::thread::ThreadGroupRef::get_group_id ( ) const
inline

Definition at line 112 of file thread_ref.hpp.

Referenced by foedus::thread::operator<<().

112 { return group_id_; }

Here is the caller graph for this function:

Epoch foedus::thread::ThreadGroupRef::get_min_in_commit_epoch ( ) const

Returns the oldest in-commit epoch of the threads in this group.

Empty in-commit epoch is skipped. If all of them are empty, returns an invalid epoch (meaning all of them will get the latest current epoch and are safe).

See also
foedus::xct::InCommitEpochGuard

Definition at line 132 of file thread_ref.cpp.

References foedus::INVALID_EPOCH, foedus::Epoch::is_valid(), foedus::assorted::memory_fence_acquire(), and foedus::Epoch::store_min().

Referenced by foedus::xct::XctManagerPimpl::handle_epoch_chime_wait_grace_period().

132  {
134  Epoch ret = INVALID_EPOCH;
135  for (const auto& t : threads_) {
136  Epoch in_commit_epoch = t.get_control_block()->in_commit_epoch_;
137  if (in_commit_epoch.is_valid()) {
138  if (!ret.is_valid()) {
139  ret = in_commit_epoch;
140  } else {
141  ret.store_min(in_commit_epoch);
142  }
143  }
144  }
145 
146  return ret;
147 }
const Epoch INVALID_EPOCH
A constant epoch object that represents an invalid epoch.
Definition: epoch.hpp:204
void memory_fence_acquire()
Equivalent to std::atomic_thread_fence(std::memory_order_acquire).
void store_min(const Epoch &other)
Kind of std::min(this, other).
Definition: epoch.hpp:153

Here is the call graph for this function:

Here is the caller graph for this function:

ThreadRef* foedus::thread::ThreadGroupRef::get_thread ( ThreadLocalOrdinal  ordinal)
inline

Returns Thread object for the given ordinal in this group.

Definition at line 115 of file thread_ref.hpp.

Referenced by foedus::thread::ThreadPoolPimpl::get_thread(), and foedus::thread::ThreadPoolPimpl::impersonate_on_numa_node().

115 { return &threads_[ordinal]; }

Here is the caller graph for this function:

ThreadRef foedus::thread::ThreadGroupRef::get_thread_ref ( ThreadLocalOrdinal  ordinal) const
inline

Returns a copied instance.

ThreadRef itself is a reference object, so it's cheap.

Definition at line 117 of file thread_ref.hpp.

117 { return threads_[ordinal]; }

Friends And Related Function Documentation

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

Definition at line 160 of file thread_ref.cpp.

160  {
161  o << "<ThreadGroupRef>";
162  o << "<group_id_>" << static_cast<int>(v.get_group_id()) << "</group_id_>";
163  o << "<threads_>";
164  for (const ThreadRef& child_thread : v.threads_) {
165  o << child_thread;
166  }
167  o << "</threads_>";
168  o << "</ThreadGroup>";
169  return o;
170 }

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