libfoedus-core
FOEDUS Core Library
foedus::thread::ThreadControlBlock Struct Reference

Shared data of ThreadPimpl. More...

Detailed Description

Shared data of ThreadPimpl.

Definition at line 48 of file thread_pimpl.hpp.

#include <thread_pimpl.hpp>

Collaboration diagram for foedus::thread::ThreadControlBlock:

Public Member Functions

 ThreadControlBlock ()=delete
 
 ~ThreadControlBlock ()=delete
 
void initialize (ThreadId my_thread_id)
 
void uninitialize ()
 

Public Attributes

uint32_t mcs_block_current_
 How many MCS blocks we allocated in this thread's current xct. More...
 
uint32_t mcs_rw_async_mapping_current_
 How many async mappings for extended RW lock we have so far. More...
 
std::atomic< bool > mcs_waiting_
 Whether this thread is waiting for some MCS lock. More...
 
soc::SharedPolling wakeup_cond_
 The thread sleeps on this conditional when it has no task. More...
 
ThreadStatus status_
 Impersonation status of this thread. More...
 
soc::SharedMutex task_mutex_
 The following variables are protected by this mutex. More...
 
ThreadTicket current_ticket_
 The most recently issued impersonation ticket. More...
 
proc::ProcName proc_name_
 Name of the procedure to execute next. More...
 
uint32_t input_len_
 Byte size of input given to the procedure. More...
 
uint32_t output_len_
 Byte size of output as the result of the procedure. More...
 
FixedErrorStack proc_result_
 Error code as the result of the procedure. More...
 
soc::SharedPolling task_complete_cond_
 When the current task has been completed, the thread signals this. More...
 
Epoch in_commit_epoch_
 
ThreadId my_thread_id_
 Used only for sanity check. More...
 
uint64_t stat_snapshot_cache_hits_
 
uint64_t stat_snapshot_cache_misses_
 

Constructor & Destructor Documentation

foedus::thread::ThreadControlBlock::ThreadControlBlock ( )
delete
foedus::thread::ThreadControlBlock::~ThreadControlBlock ( )
delete

Member Function Documentation

void foedus::thread::ThreadControlBlock::initialize ( ThreadId  my_thread_id)
inline

Definition at line 53 of file thread_pimpl.hpp.

References foedus::FixedErrorStack::clear(), foedus::assorted::FixedString< MAXLEN, CHAR >::clear(), current_ticket_, in_commit_epoch_, foedus::soc::SharedMutex::initialize(), foedus::soc::SharedPolling::initialize(), input_len_, foedus::INVALID_EPOCH, foedus::thread::kNotInitialized, mcs_block_current_, mcs_rw_async_mapping_current_, mcs_waiting_, my_thread_id_, output_len_, proc_name_, proc_result_, stat_snapshot_cache_hits_, stat_snapshot_cache_misses_, status_, task_complete_cond_, task_mutex_, and wakeup_cond_.

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

53  {
57  mcs_waiting_.store(false);
58  current_ticket_ = 0;
59  proc_name_.clear();
60  input_len_ = 0;
61  output_len_ = 0;
67  my_thread_id_ = my_thread_id;
70  }
ThreadId my_thread_id_
Used only for sanity check.
ThreadTicket current_ticket_
The most recently issued impersonation ticket.
uint32_t mcs_block_current_
How many MCS blocks we allocated in this thread's current xct.
uint32_t input_len_
Byte size of input given to the procedure.
void initialize(bool recursive=false)
std::atomic< bool > mcs_waiting_
Whether this thread is waiting for some MCS lock.
soc::SharedPolling task_complete_cond_
When the current task has been completed, the thread signals this.
soc::SharedMutex task_mutex_
The following variables are protected by this mutex.
soc::SharedPolling wakeup_cond_
The thread sleeps on this conditional when it has no task.
uint32_t mcs_rw_async_mapping_current_
How many async mappings for extended RW lock we have so far.
proc::ProcName proc_name_
Name of the procedure to execute next.
const Epoch INVALID_EPOCH
A constant epoch object that represents an invalid epoch.
Definition: epoch.hpp:204
ThreadStatus status_
Impersonation status of this thread.
void clear() noexcept
Clear string.
uint32_t output_len_
Byte size of output as the result of the procedure.
FixedErrorStack proc_result_
Error code as the result of the procedure.

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::thread::ThreadControlBlock::uninitialize ( )
inline

Definition at line 71 of file thread_pimpl.hpp.

References task_mutex_, and foedus::soc::SharedMutex::uninitialize().

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

71  {
73  }
soc::SharedMutex task_mutex_
The following variables are protected by this mutex.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

ThreadTicket foedus::thread::ThreadControlBlock::current_ticket_

The most recently issued impersonation ticket.

A session with this ticket has an exclusive ownership until it changes the status_ to kWaitingForTask.

Definition at line 120 of file thread_pimpl.hpp.

Referenced by foedus::thread::ImpersonateSession::get_result(), initialize(), foedus::thread::ImpersonateSession::is_running(), foedus::thread::ImpersonateSession::release(), and foedus::thread::ThreadRef::try_impersonate().

Epoch foedus::thread::ThreadControlBlock::in_commit_epoch_
uint32_t foedus::thread::ThreadControlBlock::input_len_

Byte size of input given to the procedure.

Definition at line 126 of file thread_pimpl.hpp.

Referenced by initialize(), and foedus::thread::ThreadRef::try_impersonate().

uint32_t foedus::thread::ThreadControlBlock::mcs_block_current_

How many MCS blocks we allocated in this thread's current xct.

reset to 0 at each transaction begin. This is in shared memory because other SOC might check this value (so far only for sanity check).

Note
So far this is a shared counter between WW and RW locks. We will thus have holes in both of them. Not a big issue, but we might want dedicated counters.

Definition at line 84 of file thread_pimpl.hpp.

Referenced by foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::cancel_new_block(), foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_cur_block(), foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_other_cur_block(), foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_rw_other_block(), foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_ww_other_block(), initialize(), foedus::thread::ThreadPimpl::initialize_once(), and foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::issue_new_block().

uint32_t foedus::thread::ThreadControlBlock::mcs_rw_async_mapping_current_
std::atomic<bool> foedus::thread::ThreadControlBlock::mcs_waiting_

Whether this thread is waiting for some MCS lock.

While this is true, the thread spins on this local variable. The lock owner updates this when it unlocks. We initially had this flag within each MCS lock node, but we anyway assume one thread can wait for at most one lock. So, we moved it to a flag in control block.

Definition at line 97 of file thread_pimpl.hpp.

Referenced by initialize(), foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::me_waiting(), and foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::other_waiting().

ThreadId foedus::thread::ThreadControlBlock::my_thread_id_

Used only for sanity check.

This thread's ID.

Definition at line 143 of file thread_pimpl.hpp.

Referenced by initialize().

uint32_t foedus::thread::ThreadControlBlock::output_len_

Byte size of output as the result of the procedure.

Definition at line 129 of file thread_pimpl.hpp.

Referenced by foedus::thread::ImpersonateSession::get_output_size(), and initialize().

proc::ProcName foedus::thread::ThreadControlBlock::proc_name_

Name of the procedure to execute next.

Empty means not set.

Definition at line 123 of file thread_pimpl.hpp.

Referenced by initialize(), and foedus::thread::ThreadRef::try_impersonate().

FixedErrorStack foedus::thread::ThreadControlBlock::proc_result_

Error code as the result of the procedure.

Definition at line 132 of file thread_pimpl.hpp.

Referenced by foedus::thread::ImpersonateSession::get_result(), and initialize().

ThreadStatus foedus::thread::ThreadControlBlock::status_

Impersonation status of this thread.

Protected by the mutex in wakeup_cond_, not the task_mutex_ below. Use the right mutex. Otherwise a lost signal is possible.

Definition at line 110 of file thread_pimpl.hpp.

Referenced by foedus::thread::ImpersonateSession::get_result(), initialize(), foedus::thread::ImpersonateSession::is_running(), foedus::thread::ThreadPimpl::is_stop_requested(), foedus::thread::operator<<(), foedus::thread::ImpersonateSession::release(), foedus::thread::ThreadRef::try_impersonate(), and foedus::thread::ThreadPimpl::uninitialize_once().

soc::SharedPolling foedus::thread::ThreadControlBlock::task_complete_cond_

When the current task has been completed, the thread signals this.

Definition at line 137 of file thread_pimpl.hpp.

Referenced by initialize(), foedus::thread::ImpersonateSession::wait(), and foedus::thread::ImpersonateSession::wait_for().

soc::SharedMutex foedus::thread::ThreadControlBlock::task_mutex_

The following variables are protected by this mutex.

Definition at line 113 of file thread_pimpl.hpp.

Referenced by initialize(), foedus::thread::ThreadRef::try_impersonate(), and uninitialize().

soc::SharedPolling foedus::thread::ThreadControlBlock::wakeup_cond_

The thread sleeps on this conditional when it has no task.

When someone else (whether in same SOC or other SOC) wants to wake up this logger, they fire this. The 'real' condition variable is the status_.

Definition at line 104 of file thread_pimpl.hpp.

Referenced by initialize(), foedus::thread::ThreadRef::try_impersonate(), and foedus::thread::ThreadPimpl::uninitialize_once().


The documentation for this struct was generated from the following file: