[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / dep / ACE_wrappers / ace / Lock_Adapter_T.h
blob4c09f7d3ae8d3b52670688fc487b08d45789ea8a
1 // -*- C++ -*-
3 //==========================================================================
4 /**
5 * @file Lock_Adapter_T.h
7 * $Id: Lock_Adapter_T.h 80826 2008-03-04 14:51:23Z wotte $
9 * Moved from Synch.h.
11 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
13 //==========================================================================
15 #ifndef ACE_LOCK_ADAPTER_T_H
16 #define ACE_LOCK_ADAPTER_T_H
17 #include /**/ "ace/pre.h"
19 #include "ace/Lock.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
22 # pragma once
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
27 /**
28 * @class ACE_Lock_Adapter
30 * @brief This is an adapter that allows applications to transparently
31 * combine the <ACE_Lock> abstract base class (which contains
32 * pure virtual methods) with any of the other concrete ACE
33 * synchronization classes (e.g., ACE_Mutex, ACE_Semaphore,
34 * ACE_RW_Mutex, etc.).
36 * This class uses a form of the Adapter pattern.
38 template <class ACE_LOCKING_MECHANISM>
39 class ACE_Lock_Adapter : public ACE_Lock
41 public:
42 typedef ACE_LOCKING_MECHANISM ACE_LOCK;
44 // = Initialization/Finalization methods.
46 /// Constructor. All locking requests will be forwarded to <lock>.
47 ACE_Lock_Adapter (ACE_LOCKING_MECHANISM &lock);
49 /// Constructor. Since no lock is provided by the user, one will be
50 /// created internally.
51 ACE_Lock_Adapter (void);
53 /// Destructor. If <lock_> was not passed in by the user, it will be
54 /// deleted.
55 virtual ~ACE_Lock_Adapter (void);
57 // = Lock accessors.
58 /// Block the thread until the lock is acquired.
59 virtual int acquire (void);
61 /// Conditionally acquire the lock (i.e., won't block).
62 virtual int tryacquire (void);
64 /// Release the lock.
65 virtual int release (void);
67 /**
68 * Block until the thread acquires a read lock. If the locking
69 * mechanism doesn't support read locks then this just calls
70 * <acquire>.
72 virtual int acquire_read (void);
74 /**
75 * Block until the thread acquires a write lock. If the locking
76 * mechanism doesn't support read locks then this just calls
77 * <acquire>.
79 virtual int acquire_write (void);
81 /// Conditionally acquire a read lock. If the locking mechanism
82 /// doesn't support read locks then this just calls <acquire>.
83 virtual int tryacquire_read (void);
85 /// Conditionally acquire a write lock. If the locking mechanism
86 /// doesn't support read locks then this just calls <acquire>.
87 virtual int tryacquire_write (void);
89 /**
90 * Conditionally try to upgrade a lock held for read to a write lock.
91 * If the locking mechanism doesn't support read locks then this just
92 * calls <acquire>. Returns 0 on success, -1 on failure.
94 virtual int tryacquire_write_upgrade (void);
96 /// Explicitly destroy the lock.
97 virtual int remove (void);
99 private:
100 /// The concrete locking mechanism that all the methods delegate to.
101 ACE_LOCKING_MECHANISM *lock_;
103 /// This flag keep track of whether we are responsible for deleting
104 /// the lock
105 bool delete_lock_;
108 ACE_END_VERSIONED_NAMESPACE_DECL
110 #if defined (__ACE_INLINE__)
111 #include "ace/Lock_Adapter_T.inl"
112 #endif /* __ACE_INLINE__ */
114 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
115 #include "ace/Lock_Adapter_T.cpp"
116 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
118 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
119 #pragma implementation ("Lock_Adapter_T.cpp")
120 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
122 #include /**/ "ace/post.h"
123 #endif /* ACE_LOCK_ADAPTER_T_H */