CMS 3D CMS Logo

WorkerChannel.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FWCore/SharedMemory
4 // Class : WorkerChannel
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Chris Jones
10 // Created: 21/01/2020
11 //
12 
13 // system include files
14 #include <cassert>
15 
16 // user include files
19 
20 //
21 // constants, enums and typedefs
22 //
23 using namespace edm::shared_memory;
24 using namespace boost::interprocess;
25 
26 namespace {
27  std::string unique_name(std::string iBase, std::string_view ID) {
28  iBase.append(ID);
29  return iBase;
30  }
31 } // namespace
32 //
33 // static data member definitions
34 //
35 
36 //
37 // constructors and destructor
38 //
39 
40 WorkerChannel::WorkerChannel(std::string const& iName, const std::string& iUniqueID)
41  : managed_shm_{open_only, iName.c_str()},
42  mutex_{open_or_create, unique_name(channel_names::kMutex, iUniqueID).c_str()},
43  cndFromController_{open_or_create, unique_name(channel_names::kConditionFromMain, iUniqueID).c_str()},
44  stop_{managed_shm_.find<bool>(channel_names::kStop).first},
45  transitionType_{managed_shm_.find<edm::Transition>(channel_names::kTransitionType).first},
46  transitionID_{managed_shm_.find<unsigned long long>(channel_names::kTransitionID).first},
47  toWorkerBufferInfo_{managed_shm_.find<BufferInfo>(channel_names::kToWorkerBufferInfo).first},
48  fromWorkerBufferInfo_{managed_shm_.find<BufferInfo>(channel_names::kFromWorkerBufferInfo).first},
49  cndToController_{open_or_create, unique_name(channel_names::kConditionToMain, iUniqueID).c_str()},
50  keepEvent_{managed_shm_.find<bool>(channel_names::kKeepEvent).first},
51  lock_{mutex_} {
52  assert(stop_);
53  assert(transitionType_);
54  assert(transitionID_);
55  assert(toWorkerBufferInfo_);
56  assert(fromWorkerBufferInfo_);
57 }
58 
59 //
60 // member functions
61 //
62 
63 //
64 // const member functions
65 //
66 
67 //
68 // static member functions
69 //
edm::shared_memory::channel_names::kToWorkerBufferInfo
constexpr char const *const kToWorkerBufferInfo
Definition: channel_names.h:29
edm::shared_memory::channel_names::kFromWorkerBufferInfo
constexpr char const *const kFromWorkerBufferInfo
Definition: channel_names.h:30
channel_names.h
cms::cuda::assert
assert(be >=bs)
edm::shared_memory::channel_names::kKeepEvent
constexpr char const *const kKeepEvent
Definition: channel_names.h:35
edm::shared_memory::channel_names::kConditionToMain
constexpr char const *const kConditionToMain
Definition: channel_names.h:33
edm::first
T first(std::pair< T, U > const &p)
Definition: ParameterSet.cc:217
edm::shared_memory::BufferInfo
Definition: BufferInfo.h:27
edm::shared_memory::channel_names::kTransitionID
constexpr char const *const kTransitionID
Definition: channel_names.h:37
edm::shared_memory::channel_names::kStop
constexpr char const *const kStop
Definition: channel_names.h:34
edm::Transition
Transition
Definition: Transition.h:12
align::ID
uint32_t ID
Definition: Definitions.h:24
WorkerChannel.h
edm::shared_memory::WorkerChannel::WorkerChannel
WorkerChannel(std::string const &iName, const std::string &iUniqueID)
Definition: WorkerChannel.cc:40
edm::shared_memory
Definition: buffer_names.h:27
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::shared_memory::channel_names::kConditionFromMain
constexpr char const *const kConditionFromMain
Definition: channel_names.h:32
edm::shared_memory::channel_names::kMutex
constexpr char const *const kMutex
Definition: channel_names.h:31
edm::shared_memory::channel_names::kTransitionType
constexpr char const *const kTransitionType
Definition: channel_names.h:36