oasys::SpinLock Class Reference

#include <SpinLock.h>

Inheritance diagram for oasys::SpinLock:

oasys::Lock oasys::Logger

List of all members.


Detailed Description

A SpinLock is a Lock that busy waits to get a lock.

The implementation supports recursive locking.

Definition at line 29 of file SpinLock.h.


Public Member Functions

 SpinLock ()
virtual ~SpinLock ()
int lock (const char *lock_user)
int unlock ()
int try_lock (const char *lock_user)

Static Public Attributes

static bool warn_on_contention_
 Control whether or not to log warnings if the spin lock is under contention.
static atomic_t total_spins_
 debugging variable
static atomic_t total_yields_
 debugging variable

Private Attributes

atomic_t lock_waiters_
 count of waiting threads

Constructor & Destructor Documentation

oasys::SpinLock::SpinLock (  )  [inline]

Definition at line 33 of file SpinLock.h.

virtual oasys::SpinLock::~SpinLock (  )  [inline, virtual]

Definition at line 34 of file SpinLock.h.


Member Function Documentation

int oasys::SpinLock::lock ( const char *  lock_user  )  [virtual]

Virtual override from Lock

Implements oasys::Lock.

Definition at line 30 of file SpinLock.cc.

References ASSERT, oasys::atomic_cmpxchg32(), oasys::atomic_decr(), oasys::atomic_incr(), oasys::Thread::current(), oasys::Lock::is_locked_by_me(), oasys::Lock::lock_count_, oasys::Lock::lock_holder_, oasys::Lock::lock_holder_name_, lock_waiters_, oasys::StackTrace::print_current_trace(), oasys::Thread::spin_yield(), total_spins_, oasys::atomic_t::value, and warn_on_contention_.

Referenced by dtn::BundleDaemon::handle_bundle_free(), oasys::Log::log_multiline(), oasys::Notifier::notify(), dtn::BlockingBundleList::pop_blocking(), oasys::Log::rotate(), oasys::Thread::thread_run(), oasys::Log::vlogf(), oasys::OnOffNotifier::wait(), and oasys::Notifier::wait().

int oasys::SpinLock::unlock (  )  [virtual]

Virtual override from Lock

Implements oasys::Lock.

Definition at line 68 of file SpinLock.cc.

References ASSERT, oasys::atomic_incr(), oasys::Lock::is_locked_by_me(), oasys::Lock::lock_count_, oasys::Lock::lock_holder_, oasys::Lock::lock_holder_name_, lock_waiters_, oasys::Thread::spin_yield(), total_yields_, and oasys::atomic_t::value.

Referenced by oasys::Log::log_multiline(), oasys::Notifier::notify(), dtn::BlockingBundleList::pop_blocking(), oasys::Log::rotate(), oasys::Thread::thread_run(), oasys::Log::vlogf(), oasys::OnOffNotifier::wait(), and oasys::Notifier::wait().

int oasys::SpinLock::try_lock ( const char *  lock_user  )  [virtual]

Virtual override from Lock

Implements oasys::Lock.

Definition at line 93 of file SpinLock.cc.

References ASSERT, oasys::atomic_cmpxchg32(), oasys::Thread::current(), oasys::Lock::is_locked_by_me(), oasys::Lock::lock_count_, oasys::Lock::lock_holder_, oasys::Lock::lock_holder_name_, and oasys::atomic_t::value.


Member Data Documentation

bool oasys::SpinLock::warn_on_contention_ [static]

Control whether or not to log warnings if the spin lock is under contention.

Definition at line 45 of file SpinLock.h.

Referenced by lock().

atomic_t oasys::SpinLock::lock_waiters_ [private]

count of waiting threads

Definition at line 48 of file SpinLock.h.

Referenced by lock(), and unlock().

atomic_t oasys::SpinLock::total_spins_ [static]

debugging variable

Definition at line 52 of file SpinLock.h.

Referenced by lock().

atomic_t oasys::SpinLock::total_yields_ [static]

debugging variable

Definition at line 53 of file SpinLock.h.

Referenced by unlock().


The documentation for this class was generated from the following files:
Generated on Sat Sep 8 08:43:55 2007 for DTN Reference Implementation by  doxygen 1.5.3