#include <IOPool/Streamer/interface/EventBuffer.h>
Definition at line 43 of file EventBuffer.h.
typedef std::vector<char> edm::EventBuffer::ByteArray [private] |
Definition at line 115 of file EventBuffer.h.
Definition at line 96 of file EventBuffer.h.
typedef std::vector<void*> edm::EventBuffer::Pool [private] |
Definition at line 117 of file EventBuffer.h.
Definition at line 97 of file EventBuffer.h.
typedef std::vector<Buffer> edm::EventBuffer::Queue [private] |
Definition at line 119 of file EventBuffer.h.
Definition at line 7 of file EventBuffer.cc.
References buffer_pool_, i, and mem_.
00007 : 00008 max_event_size_(max_event_size),max_queue_depth_(max_queue_depth), 00009 pos_(max_queue_depth-1),mem_(max_event_size * max_queue_depth), 00010 queue_(max_queue_depth), 00011 fpos_(),bpos_() 00012 { 00013 // throw if event size 0 or queue depth 0 00014 00015 for(char* i = &mem_[0]; i < &mem_[mem_.size()]; i += max_event_size) 00016 buffer_pool_.push_back(i); 00017 00018 }
edm::EventBuffer::~EventBuffer | ( | ) |
edm::EventBuffer::EventBuffer | ( | const EventBuffer & | ) | [inline, private] |
Definition at line 90 of file EventBuffer.cc.
References releaseProducerBuffer().
Referenced by edm::EventBuffer::ConsumerType::commit().
00091 { 00092 releaseProducerBuffer(v); 00093 }
Definition at line 45 of file EventBuffer.cc.
References bpos_, fpos_, max_queue_depth_, pop_cond_, push_cond_, queue_, queue_lock_, and sl.
Referenced by edm::EventBuffer::ProducerType::commit().
00046 { 00047 // get lock 00048 boost::mutex::scoped_lock sl(queue_lock_); 00049 // if full, wait for item to be removed 00050 while((bpos_+max_queue_depth_)==fpos_) { 00051 push_cond_.wait(sl); 00052 } 00053 00054 // put buffer into queue 00055 queue_[fpos_ % max_queue_depth_]=Buffer(v,len); 00056 ++fpos_; 00057 // signal consumer 00058 pop_cond_.notify_one(); 00059 // pop_cond_.notify_all(); 00060 }
Definition at line 136 of file EventBuffer.h.
References bpos_, fpos_, queue_lock_, and sl.
Referenced by stor::DataProcessManager::processCommands().
00136 { boost::mutex::scoped_lock sl(queue_lock_); return (bpos_==fpos_); }
EventBuffer::Buffer edm::EventBuffer::getConsumerBuffer | ( | ) |
Definition at line 62 of file EventBuffer.cc.
References bpos_, fpos_, max_queue_depth_, pop_cond_, push_cond_, queue_, queue_lock_, sl, and v.
00063 { 00064 // get lock 00065 boost::mutex::scoped_lock sl(queue_lock_); 00066 // if empty, wait for item to appear 00067 while(bpos_==fpos_) { 00068 pop_cond_.wait(sl); 00069 } 00070 // get a buffer from the queue and return it 00071 Buffer v = queue_[bpos_ % max_queue_depth_]; 00072 ++bpos_; 00073 // note that these operations cannot throw 00074 // signal producer 00075 push_cond_.notify_one(); 00076 // push_cond_.notify_all(); 00077 return v; 00078 }
EventBuffer::Buffer edm::EventBuffer::getProducerBuffer | ( | ) |
Definition at line 22 of file EventBuffer.cc.
References buffer_pool_, max_event_size_, pool_cond_, pool_lock_, pos_, sl, and v.
00023 { 00024 // get lock 00025 boost::mutex::scoped_lock sl(pool_lock_); 00026 // wait for buffer to appear 00027 while(pos_ < 0) { 00028 pool_cond_.wait(sl); 00029 } 00030 void* v = buffer_pool_[pos_]; 00031 --pos_; 00032 return Buffer(v,max_event_size_); 00033 }
int edm::EventBuffer::maxEventSize | ( | ) | const [inline] |
Definition at line 107 of file EventBuffer.h.
References max_event_size_.
00107 { return max_event_size_; }
int edm::EventBuffer::maxQueueDepth | ( | ) | const [inline] |
Definition at line 108 of file EventBuffer.h.
References max_queue_depth_.
00108 { return max_queue_depth_; }
Definition at line 80 of file EventBuffer.cc.
References releaseProducerBuffer().
Referenced by edm::EventBuffer::ConsumerType::release().
00081 { 00082 // should the buffer be placed back onto the queue and not released? 00083 // we got here because a commit did to occur in the consumer. 00084 // we will allow consumers to call or not call commit for now, meaning 00085 // that we cannot distinguish between exception conditions and normal 00086 // return. The buffer will always be released 00087 releaseProducerBuffer(v); 00088 }
Definition at line 35 of file EventBuffer.cc.
References buffer_pool_, pool_cond_, pool_lock_, pos_, and sl.
Referenced by commitConsumerBuffer(), edm::EventBuffer::ProducerType::release(), and releaseConsumerBuffer().
00036 { 00037 // get lock 00038 boost::mutex::scoped_lock sl(pool_lock_); 00039 ++pos_; 00040 buffer_pool_[pos_] = v; 00041 pool_cond_.notify_one(); 00042 // pool_cond_.notify_all(); 00043 }
unsigned int edm::EventBuffer::bpos_ [private] |
Definition at line 127 of file EventBuffer.h.
Referenced by commitProducerBuffer(), empty(), and getConsumerBuffer().
Pool edm::EventBuffer::buffer_pool_ [private] |
Definition at line 125 of file EventBuffer.h.
Referenced by EventBuffer(), getProducerBuffer(), and releaseProducerBuffer().
unsigned int edm::EventBuffer::fpos_ [private] |
Definition at line 127 of file EventBuffer.h.
Referenced by commitProducerBuffer(), empty(), and getConsumerBuffer().
int edm::EventBuffer::max_event_size_ [private] |
Definition at line 121 of file EventBuffer.h.
Referenced by getProducerBuffer(), and maxEventSize().
int edm::EventBuffer::max_queue_depth_ [private] |
Definition at line 122 of file EventBuffer.h.
Referenced by commitProducerBuffer(), getConsumerBuffer(), and maxQueueDepth().
ByteArray edm::EventBuffer::mem_ [private] |
boost::condition edm::EventBuffer::pool_cond_ [private] |
Definition at line 131 of file EventBuffer.h.
Referenced by getProducerBuffer(), and releaseProducerBuffer().
boost::mutex edm::EventBuffer::pool_lock_ [private] |
Definition at line 129 of file EventBuffer.h.
Referenced by getProducerBuffer(), and releaseProducerBuffer().
boost::condition edm::EventBuffer::pop_cond_ [private] |
Definition at line 132 of file EventBuffer.h.
Referenced by commitProducerBuffer(), and getConsumerBuffer().
int edm::EventBuffer::pos_ [private] |
Definition at line 123 of file EventBuffer.h.
Referenced by getProducerBuffer(), and releaseProducerBuffer().
boost::condition edm::EventBuffer::push_cond_ [private] |
Definition at line 133 of file EventBuffer.h.
Referenced by commitProducerBuffer(), and getConsumerBuffer().
Queue edm::EventBuffer::queue_ [private] |
Definition at line 126 of file EventBuffer.h.
Referenced by commitProducerBuffer(), and getConsumerBuffer().
boost::mutex edm::EventBuffer::queue_lock_ [private] |
Definition at line 130 of file EventBuffer.h.
Referenced by commitProducerBuffer(), empty(), and getConsumerBuffer().