Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:08

0001 // -*- C++ -*-
0002 //
0003 // Package:     FWCore/SharedMemory
0004 // Class  :     WorkerChannel
0005 //
0006 // Implementation:
0007 //     [Notes on implementation]
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  21/01/2020
0011 //
0012 
0013 // system include files
0014 #include <cassert>
0015 
0016 // user include files
0017 #include "FWCore/SharedMemory/interface/WorkerChannel.h"
0018 #include "FWCore/SharedMemory/interface/channel_names.h"
0019 
0020 //
0021 // constants, enums and typedefs
0022 //
0023 using namespace edm::shared_memory;
0024 using namespace boost::interprocess;
0025 
0026 namespace {
0027   std::string unique_name(std::string iBase, std::string_view ID) {
0028     iBase.append(ID);
0029     return iBase;
0030   }
0031 }  // namespace
0032 //
0033 // static data member definitions
0034 //
0035 
0036 //
0037 // constructors and destructor
0038 //
0039 
0040 WorkerChannel::WorkerChannel(std::string const& iName, const std::string& iUniqueID)
0041     : managed_shm_{open_only, iName.c_str()},
0042       mutex_{open_only, unique_name(channel_names::kMutex, iUniqueID).c_str()},
0043       cndFromController_{open_only, unique_name(channel_names::kConditionFromMain, iUniqueID).c_str()},
0044       stop_{managed_shm_.find<bool>(channel_names::kStop).first},
0045       transitionType_{managed_shm_.find<edm::Transition>(channel_names::kTransitionType).first},
0046       transitionID_{managed_shm_.find<unsigned long long>(channel_names::kTransitionID).first},
0047       toWorkerBufferInfo_{managed_shm_.find<BufferInfo>(channel_names::kToWorkerBufferInfo).first},
0048       fromWorkerBufferInfo_{managed_shm_.find<BufferInfo>(channel_names::kFromWorkerBufferInfo).first},
0049       cndToController_{open_only, unique_name(channel_names::kConditionToMain, iUniqueID).c_str()},
0050       keepEvent_{managed_shm_.find<bool>(channel_names::kKeepEvent).first},
0051       lock_{mutex_} {
0052   assert(stop_);
0053   assert(transitionType_);
0054   assert(transitionID_);
0055   assert(toWorkerBufferInfo_);
0056   assert(fromWorkerBufferInfo_);
0057 }
0058 
0059 //
0060 // member functions
0061 //
0062 
0063 //
0064 // const member functions
0065 //
0066 
0067 //
0068 // static member functions
0069 //