CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/FWCore/Framework/src/MessageReceiverForSource.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Framework
00004 // Class  :     MessageReceiverForSource
00005 // 
00006 // Implementation:
00007 //     [Notes on implementation]
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Thu Dec 30 10:09:50 CST 2010
00011 // $Id: MessageReceiverForSource.cc,v 1.2 2011/01/03 21:05:01 chrjones Exp $
00012 //
00013 
00014 // system include files
00015 #include <sys/types.h>
00016 #include <sys/ipc.h>
00017 #include <sys/msg.h>
00018 #include <errno.h>
00019 #include <string.h>
00020 
00021 // user include files
00022 #include "FWCore/Framework/interface/MessageReceiverForSource.h"
00023 #include "FWCore/Framework/src/MessageForSource.h"
00024 #include "FWCore/Utilities/interface/Exception.h"
00025 
00026 using namespace edm::multicore;
00027 //
00028 // constants, enums and typedefs
00029 //
00030 
00031 //
00032 // static data member definitions
00033 //
00034 
00035 //
00036 // constructors and destructor
00037 //
00038 MessageReceiverForSource::MessageReceiverForSource(int iQueueID):
00039 m_queueID(iQueueID),
00040 m_startIndex(0),
00041 m_numberOfConsecutiveIndices(0),
00042 m_numberToSkip(0)
00043 {
00044 }
00045 /*
00046 MessageReceiverForSource::MessageReceiverForSource(unsigned int iChildIndex, unsigned int iNumberOfChildren, unsigned int iNumberOfSequentialEvents):
00047 m_startIndex(0),
00048 m_numberOfConsecutiveIndices(0),
00049 m_numberToSkip(0),
00050 m_forkedChildIndex(iChildIndex),
00051 m_numberOfIndicesToSkip( iNumberOfSequentialEvents*(iNumberOfChildren-1) ),
00052 m_originalConsecutiveIndices(iNumberOfSequentialEvents)
00053 {
00054 }
00055  */
00056 
00057 // MessageReceiverForSource::MessageReceiverForSource(const MessageReceiverForSource& rhs)
00058 // {
00059 //    // do actual copying here;
00060 // }
00061 
00062 //MessageReceiverForSource::~MessageReceiverForSource()
00063 //{
00064 //}
00065 
00066 //
00067 // assignment operators
00068 //
00069 // const MessageReceiverForSource& MessageReceiverForSource::operator=(const MessageReceiverForSource& rhs)
00070 // {
00071 //   //An exception safe implementation is
00072 //   MessageReceiverForSource temp(rhs);
00073 //   swap(rhs);
00074 //
00075 //   return *this;
00076 // }
00077 
00078 //
00079 // member functions
00080 //
00081 void 
00082 MessageReceiverForSource::receive()
00083 {
00084    unsigned long previousStartIndex = m_startIndex;
00085    unsigned long previousConsecutiveIndices = m_numberOfConsecutiveIndices;
00086    /*
00087    //DUMMY
00088    if (m_originalConsecutiveIndices != m_numberOfConsecutiveIndices) {
00089       m_numberOfConsecutiveIndices = m_originalConsecutiveIndices;
00090       m_startIndex = m_numberOfConsecutiveIndices*m_forkedChildIndex;
00091    } else {
00092       m_startIndex += m_numberOfConsecutiveIndices+m_numberOfIndicesToSkip;
00093    }*/
00094    MessageForSource message;
00095    errno = 0;
00096    int value = msgrcv(m_queueID, &message, MessageForSource::sizeForBuffer(), MessageForSource::messageType(), 0);
00097    if (value < 0 ) {
00098       m_numberOfConsecutiveIndices=0;
00099       throw cms::Exception("MulticoreCommunicationFailure")<<"failed to receive data from controller: errno="<<errno<<" : "<<strerror(errno);
00100    }
00101    m_startIndex = message.startIndex;
00102    m_numberOfConsecutiveIndices = message.nIndices;
00103    
00104    m_numberToSkip = m_startIndex-previousStartIndex-previousConsecutiveIndices;
00105    return;
00106 }
00107 
00108 //
00109 // const member functions
00110 //
00111 
00112 //
00113 // static member functions
00114 //