diff options
author | dhinton <dhinton@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-08-04 03:53:54 +0000 |
---|---|---|
committer | dhinton <dhinton@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-08-04 03:53:54 +0000 |
commit | 937a0506cb1c0980eab5bcfdf266139e1c93e80c (patch) | |
tree | 12103be26b2e9b0cd1869d7fd72a1f8a8ec362e6 /ace/Thread_Mutex.inl | |
parent | 868bea2cbe0807f9db59c1997ede86af27fbc8e3 (diff) | |
download | ATCD-937a0506cb1c0980eab5bcfdf266139e1c93e80c.tar.gz |
ChangeLogTag:Mon Aug 4 03:26:30 UTC 2003 Don Hinton <dhinton@dresystems.com>
Diffstat (limited to 'ace/Thread_Mutex.inl')
-rw-r--r-- | ace/Thread_Mutex.inl | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/ace/Thread_Mutex.inl b/ace/Thread_Mutex.inl new file mode 100644 index 00000000000..f1031aafa48 --- /dev/null +++ b/ace/Thread_Mutex.inl @@ -0,0 +1,167 @@ +/* -*- C++ -*- */ +// $Id$ + +ACE_INLINE const ACE_thread_mutex_t & +ACE_Thread_Mutex::lock (void) const +{ +// ACE_TRACE ("ACE_Thread_Mutex::lock"); + return this->lock_; +} + +ACE_INLINE int +ACE_Thread_Mutex::acquire_read (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::acquire_read"); + return ACE_OS::thread_mutex_lock (&this->lock_); +} + +ACE_INLINE int +ACE_Thread_Mutex::acquire_write (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::acquire_write"); + return ACE_OS::thread_mutex_lock (&this->lock_); +} + +ACE_INLINE int +ACE_Thread_Mutex::tryacquire_read (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::tryacquire_read"); + return ACE_OS::thread_mutex_trylock (&this->lock_); +} + +ACE_INLINE int +ACE_Thread_Mutex::tryacquire_write (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::tryacquire_write"); + return ACE_OS::thread_mutex_trylock (&this->lock_); +} + +ACE_INLINE int +ACE_Thread_Mutex::tryacquire_write_upgrade (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::tryacquire_write_upgrade"); + return 0; +} + +ACE_INLINE int +ACE_Thread_Mutex::acquire (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::acquire"); + return ACE_OS::thread_mutex_lock (&this->lock_); +} + +ACE_INLINE int +ACE_Thread_Mutex::acquire (ACE_Time_Value &tv) +{ + // ACE_TRACE ("ACE_Thread_Mutex::acquire"); + return ACE_OS::thread_mutex_lock (&this->lock_, tv); +} + +ACE_INLINE int +ACE_Thread_Mutex::acquire (ACE_Time_Value *tv) +{ + // ACE_TRACE ("ACE_Thread_Mutex::acquire"); + return ACE_OS::thread_mutex_lock (&this->lock_, tv); +} + +ACE_INLINE int +ACE_Thread_Mutex::tryacquire (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::tryacquire"); + return ACE_OS::thread_mutex_trylock (&this->lock_); +} + +ACE_INLINE int +ACE_Thread_Mutex::release (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::release"); + return ACE_OS::thread_mutex_unlock (&this->lock_); +} + +ACE_INLINE int +ACE_Thread_Mutex::remove (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::remove"); + int result = 0; + if (this->removed_ == 0) + { + this->removed_ = 1; + result = ACE_OS::thread_mutex_destroy (&this->lock_); + } + return result; +} + +#if defined (ACE_USES_OBSOLETE_GUARD_CLASSES) +ACE_INLINE int +ACE_Thread_Mutex_Guard::locked (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex_Guard::locked"); + return this->owner_ != -1; +} + +// Explicitly acquire the lock. + +ACE_INLINE int +ACE_Thread_Mutex_Guard::acquire (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex_Guard::acquire"); + return this->owner_ = this->lock_.acquire (); +} + +// Conditionally acquire the lock (i.e., won't block). + +ACE_INLINE int +ACE_Thread_Mutex_Guard::tryacquire (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex_Guard::tryacquire"); + return this->owner_ = this->lock_.tryacquire (); +} + +// Implicitly and automatically acquire the lock. + +ACE_INLINE +ACE_Thread_Mutex_Guard::ACE_Thread_Mutex_Guard (ACE_Thread_Mutex &m, + int block) + : lock_ (m) +{ +// ACE_TRACE ("ACE_Thread_Mutex_Guard::ACE_Thread_Mutex_Guard"); + if (block) + this->acquire (); + else + this->tryacquire (); +} + +// Explicitly release the lock. + +ACE_INLINE int +ACE_Thread_Mutex_Guard::release (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex_Guard::release"); + if (this->owner_ != -1) + { + this->owner_ = -1; + return this->lock_.release (); + } + else + return 0; +} + +// Implicitly release the lock. + +ACE_INLINE +ACE_Thread_Mutex_Guard::~ACE_Thread_Mutex_Guard (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex_Guard::~ACE_Thread_Mutex_Guard"); + this->release (); +} + +// Explicitly release the lock. + +ACE_INLINE int +ACE_Thread_Mutex_Guard::remove (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex_Guard::remove"); + this->owner_ = -1; + return this->release (); +} +#endif /* ACE_USES_OBSOLETE_GUARD_CLASSES */ |