1 #ifndef FWCore_SharedMemory_ControllerChannel_h
2 #define FWCore_SharedMemory_ControllerChannel_h
24 #include "boost/interprocess/managed_shared_memory.hpp"
25 #include "boost/interprocess/sync/named_mutex.hpp"
26 #include "boost/interprocess/sync/named_condition.hpp"
27 #include "boost/interprocess/sync/scoped_lock.hpp"
36 namespace edm::shared_memory {
57 using namespace boost::interprocess;
60 using namespace boost::posix_time;
66 <<
"Failed waiting for external process while setting up the process. Timed out after " <<
maxWaitInSeconds_
76 template <
typename F,
typename FRETRY>
78 using namespace boost::interprocess;
81 using namespace boost::posix_time;
83 bool shouldContinue =
true;
84 long long int retryCount = 0;
90 <<
"Failed waiting for external process while setting up the process. Timed out after "
96 shouldContinue =
false;
98 }
while (shouldContinue);
101 template <
typename F>
103 using namespace boost::interprocess;
107 if (not
wait(lock, iTrans, iTransitionID)) {
115 template <
typename F,
typename FRETRY>
117 using namespace boost::interprocess;
121 if (not
wait(lock, iTrans, iTransitionID)) {
125 bool shouldContinue =
true;
127 using namespace boost::posix_time;
133 shouldContinue =
false;
135 }
while (shouldContinue);
149 using namespace boost::interprocess;
168 const unsigned long long*
ptr_;
174 return {*iPtr, iPtr};
181 bool wait(boost::interprocess::scoped_lock<boost::interprocess::named_mutex>&
lock,
183 unsigned long long iTransID);
184 bool wait(boost::interprocess::scoped_lock<boost::interprocess::named_mutex>&
lock);
185 bool continueWait(boost::interprocess::scoped_lock<boost::interprocess::named_mutex>&
lock);
void setupWorkerWithRetry(F &&iF, FRETRY &&iRetry)
BufferInfo * toWorkerBufferInfo()
This can be used with WriteBuffer to keep Controller and Worker in sync.
bool workerFinished() const noexcept
boost::interprocess::named_condition cndToMain_
const unsigned long long * ptr_
BufferInfo * fromWorkerBufferInfo_
bool wait(boost::interprocess::scoped_lock< boost::interprocess::named_mutex > &lock, edm::Transition iTrans, unsigned long long iTransID)
edm::Transition * transitionType_
unsigned int maxWaitInSeconds() const noexcept
BufferInfo * fromWorkerBufferInfo()
This can be used with ReadBuffer to keep Controller and Worker in sync.
unsigned long long * transitionID_
boost::interprocess::named_mutex mutex_
std::string const & sharedMemoryName() const
uint16_t mem[nChs][nEvts]
unsigned int maxWaitInSeconds_
CheckWorkerStatus initCheckWorkerStatus(unsigned long long *iPtr) const noexcept
const ControllerChannel & operator=(const ControllerChannel &)=delete
BufferInfo * toWorkerBufferInfo_
boost::interprocess::named_condition cndFromMain_
ControllerChannel(std::string const &iName, int iID, unsigned int iMaxWaitInSeconds)
const unsigned long long initValue_
boost::interprocess::managed_shared_memory managed_sm_
std::string uniqueName(std::string iBase) const
bool continueWait(boost::interprocess::scoped_lock< boost::interprocess::named_mutex > &lock)
static BufferInfo * bufferInfo(const char *iWhich, boost::interprocess::managed_shared_memory &mem)
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
std::string uniqueID() const
bool doTransition(F &&iF, edm::Transition iTrans, unsigned long long iTransitionID)
bool doTransitionWithRetry(F &&iF, FRETRY &&iRetry, edm::Transition iTrans, unsigned long long iTransitionID)
bool shouldKeepEvent() const