#include <SpinLock.h>
Inheritance diagram for oasys::SpinLock:
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 |
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.
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_, 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 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(), 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 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_, oasys::Lock::lock_holder_name_, and oasys::atomic_t::value.
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().
atomic_t oasys::SpinLock::lock_waiters_ [private] |
atomic_t oasys::SpinLock::total_spins_ [static] |
atomic_t oasys::SpinLock::total_yields_ [static] |