activemq-cpp-3.8.2
AbstractQueuedSynchronizer.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _DECAF_UTIL_CONCURRENT_LOCKS_ABSTRACTQUEUEDSYNCHRONIZER_H_
19 #define _DECAF_UTIL_CONCURRENT_LOCKS_ABSTRACTQUEUEDSYNCHRONIZER_H_
20 
21 #include <decaf/util/Config.h>
22 
25 #include <decaf/util/Collection.h>
26 #include <decaf/lang/Thread.h>
27 
28 namespace decaf {
29 namespace util {
30 namespace concurrent {
31 namespace locks {
32 
33  class SynchronizerState;
34 
36  private:
37 
38  SynchronizerState* impl;
39 
40  private:
41 
44 
45  protected:
46 
48 
49  public:
50 
55  class ConditionObject : public Condition {
56  private:
57 
59 
60  private:
61 
63  ConditionObject& operator= (const ConditionObject&);
64 
65  public:
66 
68  virtual ~ConditionObject() {}
69 
70  protected:
71 
77  virtual bool isOwnedBy(const AbstractQueuedSynchronizer* sync) const = 0;
78 
85  virtual bool hasWaiters() const = 0;
86 
93  virtual int getWaitQueueLength() const = 0;
94 
101  virtual Collection<decaf::lang::Thread*>* getWaitingThreads() const = 0;
102  };
103 
104  public:
105 
106  virtual ~AbstractQueuedSynchronizer();
107 
116  void acquire(int arg);
117 
126  void acquireShared(int arg);
127 
139  void acquireInterruptibly(int arg);
140 
151  void acquireSharedInterruptibly(int arg);
152 
160  Collection<decaf::lang::Thread*>* getExclusiveQueuedThreads() const;
161 
169  Collection<decaf::lang::Thread*>* getSharedQueuedThreads() const;
170 
177  decaf::lang::Thread* getFirstQueuedThread() const;
178 
186  Collection<decaf::lang::Thread*>* getQueuedThreads() const;
187 
195  int getQueueLength() const;
196 
208  Collection<decaf::lang::Thread*>* getWaitingThreads(const AbstractQueuedSynchronizer::ConditionObject* condition) const;
209 
222  int getWaitQueueLength(const AbstractQueuedSynchronizer::ConditionObject* condition) const;
223 
227  bool hasContended() const;
228 
232  bool hasQueuedThreads() const;
233 
244  bool hasWaiters(const AbstractQueuedSynchronizer::ConditionObject* condition) const;
245 
253  bool isQueued(decaf::lang::Thread* thread) const;
254 
262  bool owns(const AbstractQueuedSynchronizer::ConditionObject* condition) const;
263 
274  bool release(int arg);
275 
286  bool releaseShared(int arg);
287 
296  std::string toString() const;
297 
312  bool tryAcquireNanos(int arg, long long nanos);
313 
328  bool tryAcquireSharedNanos(int arg, long long nanos);
329 
330  protected:
331 
337  virtual int getState() const;
338 
345  virtual void setState(int value);
346 
358  virtual bool compareAndSetState(int expect, int update);
359 
369  virtual bool isHeldExclusively() const;
370 
390  virtual bool tryAcquire(int arg);
391 
413  virtual int tryAcquireShared(int arg);
414 
430  virtual bool tryRelease(int arg);
431 
447  virtual bool tryReleaseShared(int arg);
448 
456  virtual ConditionObject* createDefaultConditionObject();
457 
490  bool hasQueuedPredecessors() const;
491 
492  friend class SynchronizerState;
493  };
494 
495 }}}}
496 
497 #endif /* _DECAF_UTIL_CONCURRENT_LOCKS_ABSTRACTQUEUEDSYNCHRONIZER_H_ */
The root interface in the collection hierarchy.
Definition: Collection.h:68
Definition: AbstractQueuedSynchronizer.h:35
Condition object for this Synchronizer, which serves as the basis for other Lock objects.
Definition: AbstractQueuedSynchronizer.h:55
virtual ~ConditionObject()
Definition: AbstractQueuedSynchronizer.h:68
Condition factors out the Mutex monitor methods (wait, notify and notifyAll) into distinct objects to...
Definition: Condition.h:132
A Thread is a concurrent unit of execution.
Definition: Thread.h:64
#define DECAF_API
Definition: Config.h:29
Base class for locks that provide the notion of Ownership, the types of locks that are implemented us...
Definition: AbstractOwnableSynchronizer.h:38
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25