Zero  0.1.0
Classes | Static Public Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
smthread_t Class Reference

Storage Manager thread. More...

#include <smthread.h>

Classes

class  GlobalThreadList
 
struct  tcb_t
 

Static Public Member Functions

static void timeout_to_timespec (int timeout_ms, struct timespec &when)
 
static void detach_xct (xct_t *x)
 
static int lock_timeout ()
 get lock_timeout value More...
 
static void set_lock_timeout (int i)
 Set lock_timeout value. More...
 
static logrec_tget_logbuf ()
 
static logrec_tget_logbuf2 ()
 
static xct_txct ()
 return xct this thread is running More...
 
static sm_stats_tTL_stats ()
 Return thread-local statistics collected for this thread. More...
 
static long get_TL_stat (sm_stat_id s)
 
static void add_from_TL_stats (sm_stats_t &w)
 Add thread-local stats into the given structure. More...
 
static queue_based_lock_t::ext_qnodeget_me3 ()
 TLS variables Exported to sm. More...
 
static queue_based_lock_t::ext_qnodeget_me2 ()
 
static queue_based_lock_t::ext_qnodeget_me1 ()
 
static queue_based_lock_t::ext_qnodeget_xlist_mutex_node ()
 
static size_t get_tcb_depth ()
 
static void add_me_to_thread_list ()
 
static void remove_me_from_thread_list ()
 
template<typename F >
static void for_each_thread_stats (F &f)
 

Static Private Member Functions

static tcb_t *& tcb_ptr ()
 
static tcb_ttcb ()
 
static std::shared_ptr< GlobalThreadListthread_list ()
 

Private Attributes

bool _waiting
 

Friends

class smthread_init_t
 

Detailed Description

Storage Manager thread.

Attention
All threads that use storage manager functions must be of this type or of type derived from this.

Associated with an smthread_t is a POSIX thread (pthread_t). This class is in essence a wrapper around POSIX threads. The maximum number of threads a server can create depends on the availability of resources internal to the pthread implementation, (in addition to system-wide parameters), so it is not possible a priori to determine whether creation of a new thread will succeed. Failure will result in a fatal error.

The storage manager keeps its own thread-local state and provides for a little more control over the starting of threads than does the POSIX interface: you can do meaningful work between the time the thread is created and the time it starts to run. The thread constructor creates the underlying pthread_t, which then awaits permission (a pthread condition variable) to continue (signalled by smthread_t::fork).

Member Function Documentation

§ add_from_TL_stats()

void smthread_t::add_from_TL_stats ( sm_stats_t w)
static

Add thread-local stats into the given structure.

§ add_me_to_thread_list()

static void smthread_t::add_me_to_thread_list ( )
inlinestatic

§ detach_xct()

void smthread_t::detach_xct ( xct_t x)
static

skip skip

§ for_each_thread_stats()

template<typename F >
static void smthread_t::for_each_thread_stats ( F f)
inlinestatic

§ get_logbuf()

static logrec_t* smthread_t::get_logbuf ( )
inlinestatic

§ get_logbuf2()

static logrec_t* smthread_t::get_logbuf2 ( )
inlinestatic

§ get_me1()

static queue_based_lock_t::ext_qnode& smthread_t::get_me1 ( )
inlinestatic

§ get_me2()

static queue_based_lock_t::ext_qnode& smthread_t::get_me2 ( )
inlinestatic

§ get_me3()

static queue_based_lock_t::ext_qnode& smthread_t::get_me3 ( )
inlinestatic

TLS variables Exported to sm.

skip

§ get_tcb_depth()

static size_t smthread_t::get_tcb_depth ( )
inlinestatic

Tells how many transactions are nested.

§ get_TL_stat()

static long smthread_t::get_TL_stat ( sm_stat_id  s)
inlinestatic

§ get_xlist_mutex_node()

static queue_based_lock_t::ext_qnode& smthread_t::get_xlist_mutex_node ( )
inlinestatic

§ lock_timeout()

static int smthread_t::lock_timeout ( )
inlinestatic

get lock_timeout value

§ remove_me_from_thread_list()

static void smthread_t::remove_me_from_thread_list ( )
inlinestatic

§ set_lock_timeout()

static void smthread_t::set_lock_timeout ( int  i)
inlinestatic

Set lock_timeout value.

You can give a value WAIT_FOREVER, WAIT_IMMEDIATE, or a positive millisecond value. Every lock request made with WAIT_SPECIFIED_BY_THREAD will use this value.

A transaction can be given its own timeout on ss_m::begin_xct. The transaction's lock timeout is used for every lock request made with WAIT_SPECIFIED_BY_XCT. A transaction begun with WAIT_SPECIFIED_BY_THREAD will use the thread's lock_timeout for the transaction timeout.

All internal storage manager lock requests use WAIT_SPECIFIED_BY_XCT. Since the transaction can defer to the per-thread timeout, the client has control over which timeout to use by choosing the value given at ss_m::begin_xct.

§ tcb()

static tcb_t& smthread_t::tcb ( )
inlinestaticprivate

§ tcb_ptr()

static tcb_t*& smthread_t::tcb_ptr ( )
inlinestaticprivate

returns the transaction object that is currently active. Stack of transactions this thread conveys. tail is the top of the stack, which is the transaction currently outputting logs or processing REDO/UNDOs. The head is always an empty tcb_t instance. The instance is not actually needed, but it makes easier to work with existing codes (which assume only one tcb_t instance).

§ thread_list()

static std::shared_ptr<GlobalThreadList> smthread_t::thread_list ( )
inlinestaticprivate

§ timeout_to_timespec()

void smthread_t::timeout_to_timespec ( int  timeout_ms,
struct timespec &  when 
)
static

§ TL_stats()

static sm_stats_t& smthread_t::TL_stats ( )
inlinestatic

Return thread-local statistics collected for this thread.

§ xct()

static xct_t* smthread_t::xct ( )
inlinestatic

return xct this thread is running

Friends And Related Function Documentation

§ smthread_init_t

friend class smthread_init_t
friend

Member Data Documentation

§ _waiting

bool smthread_t::_waiting
private

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