CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/FWCore/MessageService/src/MainThreadMLscribe.cc

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------
00002 //
00003 // MainThreadMLscribe.cc
00004 //
00005 // Changes:
00006 //
00007 // 
00008 
00009 #include "FWCore/MessageService/interface/MainThreadMLscribe.h"
00010 #include "FWCore/MessageService/interface/ThreadQueue.h"
00011 #include "FWCore/MessageLogger/interface/ConfigurationHandshake.h"
00012 
00013 namespace edm {
00014 namespace service {
00015 
00016 MainThreadMLscribe::MainThreadMLscribe(boost::shared_ptr<ThreadQueue> tqp) 
00017   : m_queue(tqp) 
00018 {
00019 }
00020 
00021 MainThreadMLscribe::~MainThreadMLscribe() {}
00022 
00023 void  
00024 MainThreadMLscribe::
00025 runCommand(MessageLoggerQ::OpCode  opcode, void * operand)
00026 {
00027   if (MessageLoggerQ::handshaked(opcode)) {
00028     Place_for_passing_exception_ptr epp(new Pointer_to_new_exception_on_heap());
00029     ConfigurationHandshake h(operand,epp);
00030     void * v(static_cast<void *>(&h));
00031     Pointer_to_new_exception_on_heap ep;
00032     {
00033       boost::mutex::scoped_lock sl(h.m);       // get lock
00034       m_queue->produce (opcode, v);
00035       // wait for result to appear (in epp)
00036       h.c.wait(sl); // c.wait(sl) unlocks the scoped lock and sleeps till notified
00037       // ... and once the MessageLoggerScribe does h.c.notify_all() ... 
00038       ep = *h.epp;
00039       // finally, release the scoped lock by letting it go out of scope 
00040     }
00041     if ( ep ) {
00042       edm::Exception ex(*ep);
00043       throw ex;
00044     }  
00045   } else {
00046     m_queue->produce (opcode, operand);
00047   }
00048 } // runCommand
00049   
00050   
00051 
00052 } // end of namespace service  
00053 } // end of namespace edm