![]() |
![]() |
00001 #ifndef ES_RING_BUFFER_H 00002 #define ES_RING_BUFFER_H 00003 // should really write as a template... 00004 /* 00005 A ring buffer for the Storage Manager Event Server 00006 Serialized events are stored (EventMsg). The size of the 00007 buffer can be given in the constructor but the max size 00008 of each event is hardwired to 7MB (actually 7000000). 00009 This is used by the Storage Manager FragmentCollector. 00010 When the ring buffer is full it the oldest event gets 00011 overwritten. 00012 00013 30 Mar 2006 - HWKC - First implementation. 00014 1 Aug 2006 - KB - modified for new message class 00015 */ 00016 00017 #include "IOPool/Streamer/interface/EventMessage.h" 00018 00019 #include <vector> 00020 00021 // fix max size of event in each ring buffer element 00022 #define MAX_EVTBUF_SIZE 7000000 00023 00024 namespace stor 00025 { 00026 class EvtMsgRingBuffer 00027 { 00028 public: 00029 typedef std::vector<unsigned char> Buffer; 00030 00031 EvtMsgRingBuffer(unsigned int size); 00032 virtual ~EvtMsgRingBuffer(){}; 00033 00034 EventMsgView pop_front(); 00035 void push_back(EventMsgView msg); 00036 bool isEmpty(); 00037 bool isFull(); 00038 00039 private: 00040 unsigned int maxsize_; // max number of event slots in buffer 00041 int head_; // next event to come off 00042 int tail_; // last event put in 00043 int nextfree_; // next free slot to fill in 00044 std::vector<Buffer> ring_buffer_; 00045 std::vector<int> ring_totmsgsize_; 00046 }; 00047 } // end namespace stor 00048 00049 #endif 00050