CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/FWCore/MessageService/src/ThreadQueue.cc

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------
00002 //
00003 // ThreadQueue.cc
00004 //
00005 // Changes:
00006 //
00007 // 
00008 
00009 #include "FWCore/MessageService/interface/ThreadQueue.h"
00010 #include <cstring>
00011 
00012 namespace edm {
00013 namespace service {
00014 
00015 ThreadQueue::ThreadQueue() 
00016   : m_buf (buf_size, buf_depth)
00017 {
00018 }
00019 ThreadQueue::~ThreadQueue() {}
00020 
00021 void  
00022 ThreadQueue::
00023 produce(MessageLoggerQ::OpCode  o, void * operand)
00024 {
00025   SingleConsumerQ::ProducerBuffer b(m_buf);
00026   char * slot_p = static_cast<char *>(b.buffer());
00027   void * v = operand;
00028   std::memcpy(slot_p+0             , &o, sizeof(MessageLoggerQ::OpCode));
00029   std::memcpy(slot_p+sizeof(MessageLoggerQ::OpCode), &v, sizeof(void *));
00030   b.commit(buf_size);
00031 } // runCommand
00032   
00033 void  
00034 ThreadQueue::
00035 consume( MessageLoggerQ::OpCode & opcode, void * & operand )
00036 {
00037   SingleConsumerQ::ConsumerBuffer b(m_buf);  // Look -- CONSUMER buffer
00038   char * slot_p = static_cast<char *>(b.buffer());
00039   std::memcpy(&opcode , slot_p+0             , sizeof(MessageLoggerQ::OpCode));
00040   std::memcpy(&operand, slot_p+sizeof(MessageLoggerQ::OpCode), sizeof(void *));
00041   b.commit(buf_size);
00042 }
00043 
00044 
00045   
00046 
00047 } // end of namespace service  
00048 } // end of namespace edm