00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef _ACTIVEMQ_CORE_FIFOMESSAGEDISPATCHCHANNEL_H_ 00019 #define _ACTIVEMQ_CORE_FIFOMESSAGEDISPATCHCHANNEL_H_ 00020 00021 #include <activemq/util/Config.h> 00022 #include <activemq/core/MessageDispatchChannel.h> 00023 00024 #include <decaf/util/LinkedList.h> 00025 #include <decaf/lang/Pointer.h> 00026 00027 namespace activemq { 00028 namespace core { 00029 00030 class AMQCPP_API FifoMessageDispatchChannel : public MessageDispatchChannel { 00031 private: 00032 00033 bool closed; 00034 bool running; 00035 00036 mutable decaf::util::LinkedList< Pointer<MessageDispatch> > channel; 00037 00038 private: 00039 00040 FifoMessageDispatchChannel(const FifoMessageDispatchChannel&); 00041 FifoMessageDispatchChannel& operator=(const FifoMessageDispatchChannel&); 00042 00043 public: 00044 00045 FifoMessageDispatchChannel(); 00046 00047 virtual ~FifoMessageDispatchChannel(); 00048 00049 virtual void enqueue(const Pointer<MessageDispatch>& message); 00050 00051 virtual void enqueueFirst(const Pointer<MessageDispatch>& message); 00052 00053 virtual bool isEmpty() const; 00054 00055 virtual bool isClosed() const { 00056 return this->closed; 00057 } 00058 00059 virtual bool isRunning() const { 00060 return this->running; 00061 } 00062 00063 virtual Pointer<MessageDispatch> dequeue(long long timeout); 00064 00065 virtual Pointer<MessageDispatch> dequeueNoWait(); 00066 00067 virtual Pointer<MessageDispatch> peek() const; 00068 00069 virtual void start(); 00070 00071 virtual void stop(); 00072 00073 virtual void close(); 00074 00075 virtual void clear(); 00076 00077 virtual int size() const; 00078 00079 virtual std::vector<Pointer<MessageDispatch> > removeAll(); 00080 00081 public: 00082 00083 virtual void lock() { 00084 channel.lock(); 00085 } 00086 00087 virtual bool tryLock() { 00088 return channel.tryLock(); 00089 } 00090 00091 virtual void unlock() { 00092 channel.unlock(); 00093 } 00094 00095 virtual void wait() { 00096 channel.wait(); 00097 } 00098 00099 virtual void wait(long long millisecs) { 00100 channel.wait(millisecs); 00101 } 00102 00103 virtual void wait(long long millisecs, int nanos) { 00104 channel.wait(millisecs, nanos); 00105 } 00106 00107 virtual void notify() { 00108 channel.notify(); 00109 } 00110 00111 virtual void notifyAll() { 00112 channel.notifyAll(); 00113 } 00114 00115 }; 00116 00117 }} 00118 00119 #endif /* _ACTIVEMQ_CORE_FIFOMESSAGEDISPATCHCHANNEL_H_ */
1.6.1