Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Lock_Adapter_T.h
blobdbc02adb6bba1ef2ddc2fd740836578eb784aed1
1 // -*- C++ -*-
3 //==========================================================================
4 /**
5 * @file Lock_Adapter_T.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 */
9 //==========================================================================
11 #ifndef ACE_LOCK_ADAPTER_T_H
12 #define ACE_LOCK_ADAPTER_T_H
13 #include /**/ "ace/pre.h"
15 #include "ace/Lock.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 # pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
23 /**
24 * @class ACE_Lock_Adapter
26 * @brief This is an adapter that allows applications to transparently
27 * combine the ACE_Lock abstract base class (which contains
28 * pure virtual methods) with any of the other concrete ACE
29 * synchronization classes (e.g., ACE_Mutex, ACE_Semaphore,
30 * ACE_RW_Mutex, etc.).
32 * This class uses a form of the Adapter pattern.
34 template <class ACE_LOCKING_MECHANISM>
35 class ACE_Lock_Adapter : public ACE_Lock
37 public:
38 typedef ACE_LOCKING_MECHANISM ACE_LOCK;
40 // = Initialization/Finalization methods.
42 /// Constructor. All locking requests will be forwarded to @a lock.
43 ACE_Lock_Adapter (ACE_LOCKING_MECHANISM &lock);
45 /// Constructor. Since no lock is provided by the user, one will be
46 /// created internally.
47 ACE_Lock_Adapter ();
49 /// Destructor. If @c lock_ was not passed in by the user, it will be
50 /// deleted.
51 virtual ~ACE_Lock_Adapter ();
53 // = Lock accessors.
54 /// Block the thread until the lock is acquired.
55 virtual int acquire ();
57 /// Conditionally acquire the lock (i.e., won't block).
58 virtual int tryacquire ();
60 /// Release the lock.
61 virtual int release ();
63 /**
64 * Block until the thread acquires a read lock. If the locking
65 * mechanism doesn't support read locks then this just calls
66 * acquire().
68 virtual int acquire_read ();
70 /**
71 * Block until the thread acquires a write lock. If the locking
72 * mechanism doesn't support read locks then this just calls
73 * acquire().
75 virtual int acquire_write ();
77 /// Conditionally acquire a read lock. If the locking mechanism
78 /// doesn't support read locks then this just calls acquire().
79 virtual int tryacquire_read ();
81 /// Conditionally acquire a write lock. If the locking mechanism
82 /// doesn't support read locks then this just calls acquire().
83 virtual int tryacquire_write ();
85 /**
86 * Conditionally try to upgrade a lock held for read to a write lock.
87 * If the locking mechanism doesn't support read locks then this just
88 * calls acquire(). Returns 0 on success, -1 on failure.
90 virtual int tryacquire_write_upgrade ();
92 /// Explicitly destroy the lock.
93 virtual int remove ();
95 private:
96 /// The concrete locking mechanism that all the methods delegate to.
97 ACE_LOCKING_MECHANISM *lock_;
99 /// This flag keep track of whether we are responsible for deleting
100 /// the lock
101 bool delete_lock_;
104 ACE_END_VERSIONED_NAMESPACE_DECL
106 #if defined (__ACE_INLINE__)
107 #include "ace/Lock_Adapter_T.inl"
108 #endif /* __ACE_INLINE__ */
110 #include "ace/Lock_Adapter_T.cpp"
112 #include /**/ "ace/post.h"
113 #endif /* ACE_LOCK_ADAPTER_T_H */