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 50 of file SpinLock.h.

Public Member Functions

 SpinLock ()
virtual ~SpinLock ()
int lock (const char *lock_user)
 Virtual override from Lock.
int unlock ()
 Virtual override from Lock.
int try_lock (const char *lock_user)
 Virtual override from Lock.

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 54 of file SpinLock.h.

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

Definition at line 55 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 51 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_, 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::try_lock ( const char *  lock_user  )  [virtual]

Virtual override from Lock.

Implements oasys::Lock.

Definition at line 114 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_, and oasys::Lock::lock_holder_name_.

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

Virtual override from Lock.

Implements oasys::Lock.

Definition at line 89 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(), and total_yields_.

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


Member Data Documentation

atomic_t oasys::SpinLock::lock_waiters_ [private]

count of waiting threads

Definition at line 69 of file SpinLock.h.

Referenced by lock(), and unlock().

atomic_t oasys::SpinLock::total_spins_ [static]

debugging variable

Definition at line 73 of file SpinLock.h.

Referenced by lock().

atomic_t oasys::SpinLock::total_yields_ [static]

debugging variable

Definition at line 74 of file SpinLock.h.

Referenced by unlock().

bool oasys::SpinLock::warn_on_contention_ [static]

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

Definition at line 66 of file SpinLock.h.

Referenced by lock().


The documentation for this class was generated from the following files:
Generated on Thu Aug 31 21:06:07 2006 for DTN Reference Implementation by  doxygen 1.4.7