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)
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 (void)
20 if (this->delete_lock_
)
24 // Explicitly destroy the lock.
25 template <class ACE_LOCKING_MECHANISM
> int
26 ACE_Lock_Adapter
<ACE_LOCKING_MECHANISM
>::remove (void)
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 (void)
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 (void)
43 return this->lock_
->tryacquire ();
48 template <class ACE_LOCKING_MECHANISM
> int
49 ACE_Lock_Adapter
<ACE_LOCKING_MECHANISM
>::release (void)
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
58 template <class ACE_LOCKING_MECHANISM
> int
59 ACE_Lock_Adapter
<ACE_LOCKING_MECHANISM
>::acquire_read (void)
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
68 template <class ACE_LOCKING_MECHANISM
> int
69 ACE_Lock_Adapter
<ACE_LOCKING_MECHANISM
>::acquire_write (void)
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 (void)
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 (void)
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 (void)
99 return this->lock_
->tryacquire_write_upgrade ();
102 ACE_END_VERSIONED_NAMESPACE_DECL
104 #endif /* ACE_LOCK_ADAPTER_T_CPP */