smthread_t Class Reference
[Starting Up, Shutting Down, Thread Context]

Inherits sthread_t.

Inheritance diagram for smthread_t:

Inheritance graph
[legend]
Collaboration diagram for smthread_t:

Collaboration graph
[legend]
List of all members.

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).

Examples:

create_rec.cpp, log_exceed.cpp, sort_stream.cpp, startstop.cpp, and vtable_example.cpp.

Definition at line 218 of file smthread.h.

Public Types

enum  SmThreadTypes
 RTTI. More...

Public Member Functions

const atomic_thread_map_tget_fingerprint_map () const
NORET smthread_t (st_proc_t *f, void *arg, priority_t priority=t_regular, const char *name=0, timeout_in_ms lockto=WAIT_FOREVER, unsigned stack_size=default_stack)
 Normal constructor for a storage manager client.
NORET smthread_t (priority_t priority=t_regular, const char *name=0, timeout_in_ms lockto=WAIT_FOREVER, unsigned stack_size=default_stack)
 Normal constructor for a storage manager client.
w_rc_t join (timeout_in_ms timeout=WAIT_FOREVER)
 Returns when this thread ends.
virtual void before_run ()
 Called before run() is called.
virtual void run ()=0
 Main work routine.
virtual void after_run ()
 Call when run finishes, before join() returns.
virtual int thread_type ()
 RTTI.
timeout_in_ms lock_timeout ()
 get lock_timeout value
void lock_timeout (timeout_in_ms i)
 Set lock_timeout value.
xct_txct ()
 return xct this thread is running
xct_txct () const
 return xct this thread is running
sm_stats_info_tTL_stats ()
 Return thread-local statistics collected for this thread.
void add_from_TL_stats (sm_stats_info_t &w) const
 Add thread-local stats into the given structure.
bool generate_log_warnings () const
void set_generate_log_warnings (bool b)
queue_based_lock_t::ext_qnode & get_me3 ()
 TLS variables Exported to sm.
queue_based_lock_t::ext_qnode & get_me2 ()
queue_based_lock_t::ext_qnode & get_me1 ()
queue_based_lock_t::ext_qnode & get_log_me_node ()
queue_based_lock_t::ext_qnode & get_xlist_mutex_node ()
queue_based_lock_t::ext_qnode & get_1thread_log_me ()
queue_based_lock_t::ext_qnode & get_1thread_xct_me ()
queue_based_lock_t::ext_qnode & get_xct_t_me_node ()
tcb_t::ordinal_number_t & get__ordinal ()
int & get___metarecs ()
int & get___metarecs_in ()
char * get_kc_buf ()
cvec_tget_kc_vec ()
char * get_page_check_map ()

Static Public Member Functions

static void for_each_smthread (SmthreadFunc &f)
 Iterator over all smthreads. Thread-safe and so use carefully.
static smthread_tme ()
 Return currently-running smthread.


Member Enumeration Documentation

enum smthread_t::SmThreadTypes

RTTI.

Run-time type info: Derived threads are expected to add thread types and override thread_type()

Definition at line 413 of file smthread.h.


Constructor & Destructor Documentation

NORET smthread_t::smthread_t ( st_proc_t *  f,
void *  arg,
priority_t  priority = t_regular,
const char *  name = 0,
timeout_in_ms  lockto = WAIT_FOREVER,
unsigned  stack_size = default_stack 
)

Normal constructor for a storage manager client.

Parameters:
[in] f Stored in thread for client's convenience, may be used in run() method.
[in] arg Stored in thread for client's convenience, may be used in run() method.
[in] priority Required, but not used in storage manager.
[in] name Optional thread name, used for debugging.
[in] lockto Timeout for lock waiting. See timeout_in_ms.
[in] stack_size Best to use default.

NORET smthread_t::smthread_t ( priority_t  priority = t_regular,
const char *  name = 0,
timeout_in_ms  lockto = WAIT_FOREVER,
unsigned  stack_size = default_stack 
)

Normal constructor for a storage manager client.

Parameters:
[in] priority Required, but not used in storage manager.
[in] name Optional thread name, used for debugging.
[in] lockto Timeout for lock waiting. See timeout_in_ms.
[in] stack_size Best to use default.


Member Function Documentation

w_rc_t smthread_t::join ( timeout_in_ms  timeout = WAIT_FOREVER  ) 

Returns when this thread ends.

Parameters:
[in] timeout Not used.
Errors: -ePINACTIVE: if the thread ended while holding a pinned record. -eINTRANS: if the thread ended while attached to a transaction.

Reimplemented from sthread_t.

virtual int smthread_t::thread_type (  )  [inline, virtual]

RTTI.

Run-time type info: Derived threads are expected to add thread types and override thread_type()

Definition at line 419 of file smthread.h.

static void smthread_t::for_each_smthread ( SmthreadFunc f  )  [static]

Iterator over all smthreads. Thread-safe and so use carefully.

Parameters:
[in] f Callback function. For each smthread, this calls the callback function f. Because this grabs a lock on the list of all shore threads, whether or not they are smthreads, this prevents new threads from starting and old ones from finishing, so don't use with long-running functions.

void smthread_t::lock_timeout ( timeout_in_ms  i  )  [inline]

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.

Definition at line 482 of file smthread.h.

static smthread_t* smthread_t::me (  )  [inline, static]

Return currently-running smthread.

Note:
Assumes all threads are smthreads

Reimplemented from sthread_t.

Definition at line 498 of file smthread.h.

References sthread_t::me().

Here is the call graph for this function:


The documentation for this class was generated from the following file:
Generated on Wed Jul 7 17:22:43 2010 for Shore Storage Manager by  doxygen 1.4.7