activemq-cpp-3.9.5
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
23
27
28namespace activemq {
29namespace core {
30
31 using decaf::lang::ArrayPointer;
32
33 class AMQCPP_API SimplePriorityMessageDispatchChannel : public MessageDispatchChannel {
34 private:
35
36 static const int MAX_PRIORITIES;
37
38 bool closed;
39 bool running;
40
42
44
45 int enqueued;
46
47 private:
48
49 SimplePriorityMessageDispatchChannel(const SimplePriorityMessageDispatchChannel&);
50 SimplePriorityMessageDispatchChannel& operator=(const SimplePriorityMessageDispatchChannel&);
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
74
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_ */
#define AMQCPP_API
Definition Config.h:30
Definition MessageDispatchChannel.h:34
virtual void notifyAll()
Signals the waiters on this object that it can now wake up and continue.
Definition SimplePriorityMessageDispatchChannel.h:119
virtual std::vector< Pointer< MessageDispatch > > removeAll()
Remove all messages that are currently in the Channel and return them as a list of Messages.
virtual void lock()
Locks the object.
Definition SimplePriorityMessageDispatchChannel.h:91
virtual void clear()
Clear the Channel, all pending messages are removed.
virtual bool isClosed() const
Definition SimplePriorityMessageDispatchChannel.h:63
virtual void unlock()
Unlocks the object.
Definition SimplePriorityMessageDispatchChannel.h:99
virtual void enqueueFirst(const Pointer< MessageDispatch > &message)
Add a message to the front of the Channel.
virtual void start()
Starts dispatch of messages from the Channel.
virtual Pointer< MessageDispatch > dequeueNoWait()
Used to get an enqueued message if there is one queued right now.
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
virtual void notify()
Signals a waiter on this object that it can now wake up and continue.
Definition SimplePriorityMessageDispatchChannel.h:115
virtual void stop()
Stops dispatch of message from the Channel.
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
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 void close()
Close this channel no messages will be dispatched after this method is called.
virtual void wait()
Waits on a signal from this object, which is generated by a call to Notify.
Definition SimplePriorityMessageDispatchChannel.h:103
virtual Pointer< MessageDispatch > dequeue(long long timeout)
Used to get an enqueued message.
virtual Pointer< MessageDispatch > peek() const
Peek in the Queue and return the first message in the Channel without removing it from the channel.
virtual void enqueue(const Pointer< MessageDispatch > &message)
Add a Message to the Channel behind all pending message.
virtual bool isRunning() const
Definition SimplePriorityMessageDispatchChannel.h:67
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
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
A complete implementation of the List interface using a doubly linked list data structure.
Definition LinkedList.h:55
Mutex object that offers recursive support on all platforms as well as providing the ability to use t...
Definition Mutex.h:39
Definition ActiveMQTempDestination.h:29
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition CachedConsumer.h:24