Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / ACE / ace / Lock_Adapter_T.cpp
blob9bf13d3fc9a303ee7f5b5acbd5e7a46701df461e
1 #ifndef ACE_LOCK_ADAPTER_T_CPP
2 #define ACE_LOCK_ADAPTER_T_CPP
4 #include "ace/Lock_Adapter_T.h"
5 #include "ace/OS_Memory.h" // for ACE_NEW
7 #if !defined (ACE_LACKS_PRAGMA_ONCE)
8 # pragma once
9 #endif /* ACE_LACKS_PRAGMA_ONCE */
11 #if !defined (__ACE_INLINE__)
12 #include "ace/Lock_Adapter_T.inl"
13 #endif /* __ACE_INLINE__ */
15 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
17 template <class ACE_LOCKING_MECHANISM>
18 ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::~ACE_Lock_Adapter ()
20 if (this->delete_lock_)
21 delete this->lock_;
24 // Explicitly destroy the lock.
25 template <class ACE_LOCKING_MECHANISM> int
26 ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::remove ()
28 return this->lock_->remove ();
31 // Block the thread until the lock is acquired.
32 template <class ACE_LOCKING_MECHANISM> int
33 ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::acquire ()
35 return this->lock_->acquire ();
38 // Conditionally acquire the lock (i.e., won't block).
40 template <class ACE_LOCKING_MECHANISM> int
41 ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::tryacquire ()
43 return this->lock_->tryacquire ();
46 // Release the lock.
48 template <class ACE_LOCKING_MECHANISM> int
49 ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::release ()
51 return this->lock_->release ();
54 // Block until the thread acquires a read lock. If the locking
55 // mechanism doesn't support read locks then this just calls
56 // <acquire>.
58 template <class ACE_LOCKING_MECHANISM> int
59 ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::acquire_read ()
61 return this->lock_->acquire_read ();
64 // Block until the thread acquires a write lock. If the locking
65 // mechanism doesn't support read locks then this just calls
66 // <acquire>.
68 template <class ACE_LOCKING_MECHANISM> int
69 ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::acquire_write ()
71 return this->lock_->acquire_write ();
74 // Conditionally acquire a read lock. If the locking mechanism
75 // doesn't support read locks then this just calls <acquire>.
77 template <class ACE_LOCKING_MECHANISM> int
78 ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::tryacquire_read ()
80 return this->lock_->tryacquire_read ();
83 // Conditionally acquire a write lock. If the locking mechanism
84 // doesn't support write locks then this just calls <acquire>.
86 template <class ACE_LOCKING_MECHANISM> int
87 ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::tryacquire_write ()
89 return this->lock_->tryacquire_write ();
92 // Conditionally try to upgrade a lock held for read to a write lock.
93 // If the locking mechanism doesn't support read locks then this just
94 // calls <acquire>. Returns 0 on success, -1 on failure.
96 template <class ACE_LOCKING_MECHANISM> int
97 ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::tryacquire_write_upgrade ()
99 return this->lock_->tryacquire_write_upgrade ();
102 ACE_END_VERSIONED_NAMESPACE_DECL
104 #endif /* ACE_LOCK_ADAPTER_T_CPP */