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"
28 #include "boost/date_time/posix_time/posix_time_types.hpp"
37 namespace edm::shared_memory {
58 using namespace boost::interprocess;
61 using namespace boost::posix_time;
67 <<
"Failed waiting for external process while setting up the process. Timed out after " <<
maxWaitInSeconds_
77 template <
typename F,
typename FRETRY>
79 using namespace boost::interprocess;
82 using namespace boost::posix_time;
84 bool shouldContinue =
true;
85 long long int retryCount = 0;
91 <<
"Failed waiting for external process while setting up the process. Timed out after "
97 shouldContinue =
false;
99 }
while (shouldContinue);
102 template <
typename F>
104 using namespace boost::interprocess;
108 if (not
wait(lock, iTrans, iTransitionID)) {
116 template <
typename F,
typename FRETRY>
118 using namespace boost::interprocess;
122 if (not
wait(lock, iTrans, iTransitionID)) {
126 bool shouldContinue =
true;
128 using namespace boost::posix_time;
134 shouldContinue =
false;
136 }
while (shouldContinue);
150 using namespace boost::interprocess;
169 const unsigned long long*
ptr_;
175 return {*iPtr, iPtr};
182 bool wait(boost::interprocess::scoped_lock<boost::interprocess::named_mutex>&
lock,
184 unsigned long long iTransID);
185 bool wait(boost::interprocess::scoped_lock<boost::interprocess::named_mutex>&
lock);
186 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