|
activemq-cpp-3.3.0
|
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() throw( decaf::lang::exceptions::RuntimeException ) { 00084 channel.lock(); 00085 } 00086 00087 virtual bool tryLock() throw( decaf::lang::exceptions::RuntimeException ) { 00088 return channel.tryLock(); 00089 } 00090 00091 virtual void unlock() throw( decaf::lang::exceptions::RuntimeException ) { 00092 channel.unlock(); 00093 } 00094 00095 virtual void wait() throw( decaf::lang::exceptions::RuntimeException, 00096 decaf::lang::exceptions::IllegalMonitorStateException, 00097 decaf::lang::exceptions::InterruptedException ) { 00098 00099 channel.wait(); 00100 } 00101 00102 virtual void wait( long long millisecs ) 00103 throw( decaf::lang::exceptions::RuntimeException, 00104 decaf::lang::exceptions::IllegalMonitorStateException, 00105 decaf::lang::exceptions::InterruptedException ) { 00106 00107 channel.wait( millisecs ); 00108 } 00109 00110 virtual void wait( long long millisecs, int nanos ) 00111 throw( decaf::lang::exceptions::RuntimeException, 00112 decaf::lang::exceptions::IllegalArgumentException, 00113 decaf::lang::exceptions::IllegalMonitorStateException, 00114 decaf::lang::exceptions::InterruptedException ) { 00115 00116 channel.wait( millisecs, nanos ); 00117 } 00118 00119 virtual void notify() throw( decaf::lang::exceptions::RuntimeException, 00120 decaf::lang::exceptions::IllegalMonitorStateException ) { 00121 00122 channel.notify(); 00123 } 00124 00125 virtual void notifyAll() throw( decaf::lang::exceptions::RuntimeException, 00126 decaf::lang::exceptions::IllegalMonitorStateException ) { 00127 00128 channel.notifyAll(); 00129 } 00130 00131 }; 00132 00133 }} 00134 00135 #endif /* _ACTIVEMQ_CORE_FIFOMESSAGEDISPATCHCHANNEL_H_ */