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()},
46  transitionID_{managed_shm_.find<unsigned long long>(channel_names::kTransitionID).first},
49  cndToController_{open_or_create, unique_name(channel_names::kConditionToMain, iUniqueID).c_str()},
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 //
constexpr char const *const kConditionToMain
Definition: channel_names.h:33
WorkerChannel(std::string const &iName, const std::string &iUniqueID)
constexpr char const *const kConditionFromMain
Definition: channel_names.h:32
constexpr char const *const kStop
Definition: channel_names.h:34
uint32_t ID
Definition: Definitions.h:26
constexpr char const *const kTransitionType
Definition: channel_names.h:36
boost::interprocess::managed_shared_memory managed_shm_
Definition: WorkerChannel.h:98
unsigned long long * transitionID_
constexpr char const *const kMutex
Definition: channel_names.h:31
Transition
Definition: Transition.h:12
constexpr char const *const kKeepEvent
Definition: channel_names.h:35
boost::interprocess::named_condition cndFromController_
constexpr char const *const kFromWorkerBufferInfo
Definition: channel_names.h:30
constexpr char const *const kTransitionID
Definition: channel_names.h:37
constexpr char const *const kToWorkerBufferInfo
Definition: channel_names.h:29
boost::interprocess::scoped_lock< boost::interprocess::named_mutex > lock_
boost::interprocess::named_condition cndToController_
T first(std::pair< T, U > const &p)
boost::interprocess::named_mutex mutex_