Zero  0.1.0
Public Member Functions | Private Types | Private Attributes | List of all members
occ_rwlock Struct Reference

A multiple-reader/single-writer lock based on pthreads (blocking) More...

#include <latches.h>

Public Member Functions

 occ_rwlock ()
 
 ~occ_rwlock ()
 
void acquire_read ()
 The normal way to acquire a read lock. More...
 
void release_read ()
 The normal way to release a read lock. More...
 
void acquire_write ()
 The normal way to acquire a write lock. More...
 
void release_write ()
 The normal way to release a write lock. More...
 

Private Types

enum  { WRITER = 1, READER = 2 }
 

Private Attributes

unsigned int volatile _active_count
 
occ_rlock _read_lock
 
occ_wlock _write_lock
 
pthread_mutex_t _read_write_mutex
 
pthread_cond_t _read_cond
 
pthread_cond_t _write_cond
 

Detailed Description

A multiple-reader/single-writer lock based on pthreads (blocking)

Use this to protect data structures that get hammered by reads and where updates are very rare. It is used in the storage manager by the histograms (histo.cpp), and in place of some mutexen, where strict exclusion isn't required.

This lock is used in the storage manager by the checkpoint thread (the only acquire-writer) and other threads to be sure they don't do certain nasty things when a checkpoint is going on.

The idiom for using these locks is that the qnode is on a threads's stack, so the qnode implicitly identifies the owning thread.

See also: REFSYNC

Member Enumeration Documentation

§ anonymous enum

anonymous enum
private

skip

Enumerator
WRITER 
READER 

Constructor & Destructor Documentation

§ occ_rwlock()

occ_rwlock::occ_rwlock ( )

§ ~occ_rwlock()

occ_rwlock::~occ_rwlock ( )

Member Function Documentation

§ acquire_read()

void occ_rwlock::acquire_read ( )

The normal way to acquire a read lock.

§ acquire_write()

void occ_rwlock::acquire_write ( )

The normal way to acquire a write lock.

§ release_read()

void occ_rwlock::release_read ( )

The normal way to release a read lock.

§ release_write()

void occ_rwlock::release_write ( )

The normal way to release a write lock.

Member Data Documentation

§ _active_count

unsigned int volatile occ_rwlock::_active_count
private

§ _read_cond

pthread_cond_t occ_rwlock::_read_cond
private

§ _read_lock

occ_rlock occ_rwlock::_read_lock
private

§ _read_write_mutex

pthread_mutex_t occ_rwlock::_read_write_mutex
private

§ _write_cond

pthread_cond_t occ_rwlock::_write_cond
private

§ _write_lock

occ_wlock occ_rwlock::_write_lock
private

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