Zero  0.1.0
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
RawLockBackgroundThread Class Reference

The background thread for pre-allocation and garbage collection of object pools used in RAW-style lock manager. More...

#include <lock_raw.h>

Public Member Functions

 RawLockBackgroundThread (const sm_options &options, GcPoolForest< RawLock > *lock_pool, GcPoolForest< RawXct > *xct_pool)
 
 ~RawLockBackgroundThread ()
 
void start ()
 
void stop_synchronous ()
 
void wakeup ()
 
void run_main ()
 

Static Public Member Functions

static void * pthread_main (void *t)
 

Protected Attributes

pthread_t _thread
 
pthread_attr_t _join_attr
 
pthread_mutex_t _interval_mutex
 
pthread_cond_t _interval_cond
 
bool _stop_requested
 
bool _running
 
int _dummy_lsn_lock
 
int _dummy_lsn_xct
 
uint32_t _generation_count
 
uint32_t _init_generation_count
 
uint32_t _free_segment_count
 
uint32_t _max_segment_count
 
uint32_t _internal_milliseconds
 
uint32_t _lockpool_initseg
 
uint32_t _xctpool_initseg
 
size_t _lockpool_segsize
 
size_t _xctpool_segsize
 
GcPoolForest< RawLock > * _lock_pool
 
GcPoolForest< RawXct > * _xct_pool
 

Detailed Description

The background thread for pre-allocation and garbage collection of object pools used in RAW-style lock manager.

The background thread takes intervals between pre-allocation and garbage collection, but might be invoked by hurried transactions by calling wakeup() method.

Constructor & Destructor Documentation

§ RawLockBackgroundThread()

RawLockBackgroundThread::RawLockBackgroundThread ( const sm_options options,
GcPoolForest< RawLock > *  lock_pool,
GcPoolForest< RawXct > *  xct_pool 
)

§ ~RawLockBackgroundThread()

RawLockBackgroundThread::~RawLockBackgroundThread ( )

Member Function Documentation

§ pthread_main()

void * RawLockBackgroundThread::pthread_main ( void *  t)
static

Handler for pthread_create. Parameter is this.

§ run_main()

void RawLockBackgroundThread::run_main ( )

Gut of this class.

§ start()

void RawLockBackgroundThread::start ( )

Start running this thread.

§ stop_synchronous()

void RawLockBackgroundThread::stop_synchronous ( )

Request this thread to stop and wait until it stops.

§ wakeup()

void RawLockBackgroundThread::wakeup ( )

Wakeup this thread to do its job.

Member Data Documentation

§ _dummy_lsn_lock

int RawLockBackgroundThread::_dummy_lsn_lock
protected

When there is no log manager, we still need to do something to invoke retiring. We use this counter to immitate LSN moving forward and retire the last generation. It's unsafe, but so are all no-log executions.

§ _dummy_lsn_xct

int RawLockBackgroundThread::_dummy_lsn_xct
protected

§ _free_segment_count

uint32_t RawLockBackgroundThread::_free_segment_count
protected

We start pre-allocating segments in current generation if we have less than this number of free segments. sm_rawlock_gc_free_segment_count.

§ _generation_count

uint32_t RawLockBackgroundThread::_generation_count
protected

We start retiring generations when there are more than this number of generations. sm_rawlock_gc_generation_count.

§ _init_generation_count

uint32_t RawLockBackgroundThread::_init_generation_count
protected

When we start up, we pre-allocate this many generations. sm_rawlock_gc_init_generation_count.

§ _internal_milliseconds

uint32_t RawLockBackgroundThread::_internal_milliseconds
protected

How many milliseconds do we sleep as interval. sm_rawlock_gc_interval_ms.

§ _interval_cond

pthread_cond_t RawLockBackgroundThread::_interval_cond
protected

Pthread Condition for taking internal sleep.

§ _interval_mutex

pthread_mutex_t RawLockBackgroundThread::_interval_mutex
protected

Pthread Mutex for taking internal sleep.

§ _join_attr

pthread_attr_t RawLockBackgroundThread::_join_attr
protected

To join the thread.

§ _lock_pool

GcPoolForest<RawLock>* RawLockBackgroundThread::_lock_pool
protected

The RawLock pool to take care of.

§ _lockpool_initseg

uint32_t RawLockBackgroundThread::_lockpool_initseg
protected

When we create a new lock generation, we initially pre-allocate this number of segments. sm_rawlock_lockpool_initseg.

§ _lockpool_segsize

size_t RawLockBackgroundThread::_lockpool_segsize
protected

How many objects we create in each segment of _lock_pool. sm_rawlock_lockpool_segsize.

§ _max_segment_count

uint32_t RawLockBackgroundThread::_max_segment_count
protected

We advance generation when there are this number of segments in current generation. sm_rawlock_gc_max_segment_count.

§ _running

bool RawLockBackgroundThread::_running
protected

§ _stop_requested

bool RawLockBackgroundThread::_stop_requested
protected

Turned on to stop this thread.

§ _thread

pthread_t RawLockBackgroundThread::_thread
protected

The background pthread thread.

§ _xct_pool

GcPoolForest<RawXct>* RawLockBackgroundThread::_xct_pool
protected

The RawXct pool to take care of.

§ _xctpool_initseg

uint32_t RawLockBackgroundThread::_xctpool_initseg
protected

When we create a new xct generation, we initially pre-allocate this number of segments. sm_rawlock_xctpool_initseg.

§ _xctpool_segsize

size_t RawLockBackgroundThread::_xctpool_segsize
protected

How many objects we create in each segment of _xct_pool. sm_rawlock_xctpool_segsize.


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