activemq-cpp-3.8.2
SimplePriorityMessageDispatchChannel.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 _ACTIVEMQ_CORE_SIMPLEPRIORITYMESSAGEDISPATCHCHANNEL_H_
19 #define _ACTIVEMQ_CORE_SIMPLEPRIORITYMESSAGEDISPATCHCHANNEL_H_
20 
21 #include <activemq/util/Config.h>
23 
24 #include <decaf/util/LinkedList.h>
27 
28 namespace activemq {
29 namespace core {
30 
32 
34  private:
35 
36  static const int MAX_PRIORITIES;
37 
38  bool closed;
39  bool running;
40 
41  mutable decaf::util::concurrent::Mutex mutex;
42 
44 
45  int enqueued;
46 
47  private:
48 
51 
52  public:
53 
56 
57  virtual void enqueue(const Pointer<MessageDispatch>& message);
58 
59  virtual void enqueueFirst(const Pointer<MessageDispatch>& message);
60 
61  virtual bool isEmpty() const;
62 
63  virtual bool isClosed() const {
64  return this->closed;
65  }
66 
67  virtual bool isRunning() const {
68  return this->running;
69  }
70 
71  virtual Pointer<MessageDispatch> dequeue(long long timeout);
72 
73  virtual Pointer<MessageDispatch> dequeueNoWait();
74 
75  virtual Pointer<MessageDispatch> peek() const;
76 
77  virtual void start();
78 
79  virtual void stop();
80 
81  virtual void close();
82 
83  virtual void clear();
84 
85  virtual int size() const;
86 
87  virtual std::vector<Pointer<MessageDispatch> > removeAll();
88 
89  public:
90 
91  virtual void lock() {
92  mutex.lock();
93  }
94 
95  virtual bool tryLock() {
96  return mutex.tryLock();
97  }
98 
99  virtual void unlock() {
100  mutex.unlock();
101  }
102 
103  virtual void wait() {
104  mutex.wait();
105  }
106 
107  virtual void wait(long long millisecs) {
108  mutex.wait(millisecs);
109  }
110 
111  virtual void wait(long long millisecs, int nanos) {
112  mutex.wait(millisecs, nanos);
113  }
114 
115  virtual void notify() {
116  mutex.notify();
117  }
118 
119  virtual void notifyAll() {
120  mutex.notifyAll();
121  }
122 
123  private:
124 
126 
127  Pointer<MessageDispatch> removeFirst();
128 
129  Pointer<MessageDispatch> getFirst() const;
130 
131  };
132 
133 }}
134 
135 #endif /* _ACTIVEMQ_CORE_SIMPLEPRIORITYMESSAGEDISPATCHCHANNEL_H_ */
virtual void notify()
Signals a waiter on this object that it can now wake up and continue.
Definition: SimplePriorityMessageDispatchChannel.h:115
virtual bool tryLock()
Attempts to Lock the object, if the lock is already held by another thread than this method returns f...
Definition: SimplePriorityMessageDispatchChannel.h:95
Mutex object that offers recursive support on all platforms as well as providing the ability to use t...
Definition: Mutex.h:39
Definition: SimplePriorityMessageDispatchChannel.h:33
#define AMQCPP_API
Definition: Config.h:30
virtual void unlock()
Unlocks the object.
Definition: SimplePriorityMessageDispatchChannel.h:99
virtual void notifyAll()
Signals the waiters on this object that it can now wake up and continue.
Definition: SimplePriorityMessageDispatchChannel.h:119
virtual bool isClosed() const
Definition: SimplePriorityMessageDispatchChannel.h:63
virtual void wait()
Waits on a signal from this object, which is generated by a call to Notify.
Definition: SimplePriorityMessageDispatchChannel.h:103
Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition: ArrayPointer.h:51
virtual void wait(long long millisecs, int nanos)
Waits on a signal from this object, which is generated by a call to Notify.
Definition: SimplePriorityMessageDispatchChannel.h:111
virtual bool isRunning() const
Definition: SimplePriorityMessageDispatchChannel.h:67
virtual void lock()
Locks the object.
Definition: SimplePriorityMessageDispatchChannel.h:91
Definition: MessageDispatchChannel.h:34
Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition: Pointer.h:53
virtual void wait(long long millisecs)
Waits on a signal from this object, which is generated by a call to Notify.
Definition: SimplePriorityMessageDispatchChannel.h:107
A complete implementation of the List interface using a doubly linked list data structure.
Definition: LinkedList.h:55