00001 /*------------------------------------------------------------------------------ 00002 Name: RamQueuePlugin.h 00003 Project: xmlBlaster.org 00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file 00005 ------------------------------------------------------------------------------*/ 00006 00017 #ifndef _UTIL_QUEUE_RAMQUEUE_H 00018 #define _UTIL_QUEUE_RAMQUEUE_H 00019 00020 #include <util/xmlBlasterDef.h> 00021 #include <util/ReferenceHolder.h> 00022 #include <util/queue/I_Queue.h> 00023 #include <util/queue/MsgQueueEntry.h> 00024 #include <util/thread/ThreadImpl.h> 00025 #include <util/I_Log.h> 00026 #include <set> 00027 00028 namespace org { namespace xmlBlaster { namespace util { namespace queue { 00029 00030 typedef std::set<EntryType, std::greater<EntryType> > StorageType; 00031 00032 class Dll_Export RamQueuePlugin : public I_Queue 00033 { 00034 protected: 00035 std::string ME; 00036 org::xmlBlaster::util::Global& global_; 00037 org::xmlBlaster::util::I_Log& log_; 00038 org::xmlBlaster::util::qos::storage::ClientQueueProperty property_; 00039 StorageType storage_; 00040 long numOfBytes_; 00041 org::xmlBlaster::util::thread::Mutex accessMutex_; 00042 00043 public: 00044 RamQueuePlugin(org::xmlBlaster::util::Global& global, const org::xmlBlaster::util::qos::storage::ClientQueueProperty& property); 00045 00046 RamQueuePlugin(const RamQueuePlugin& queue); 00047 00048 RamQueuePlugin& operator =(const RamQueuePlugin& queue); 00049 00050 virtual ~RamQueuePlugin(); 00051 00059 void put(const MsgQueueEntry &entry); 00060 00067 const std::vector<EntryType> peekWithSamePriority(long maxNumOfEntries=-1, long maxNumOfBytes=-1) const; 00068 00073 long randomRemove(const std::vector<EntryType>::const_iterator &start, const std::vector<EntryType>::const_iterator &end); 00074 00079 long getNumOfEntries() const; 00080 00085 long getMaxNumOfEntries() const; 00086 00094 int64_t getNumOfBytes() const; 00095 00100 int64_t getMaxNumOfBytes() const; 00101 00105 void clear(); 00106 00110 bool empty() const; 00111 00117 std::string getType() { static std::string type = "RAM"; return type; } 00118 00124 std::string getVersion() { static std::string version = "1.0"; return version; } 00125 00126 void destroy() { return; } 00127 }; 00128 00129 }}}} // namespace 00130 00131 #endif 00132