83 template<
typename BackendType,
typename BackendSpecificDataType,
typename UserDataType>
84 boost::shared_ptr<AsyncNDRegisterAccessor<UserDataType>>
subscribe(boost::shared_ptr<BackendType> backend,
85 size_t domainId,
bool activate,
RegisterPath name,
size_t numberOfWords,
size_t wordOffsetInRegister,
92 boost::shared_ptr<Domain>
getDomain(
size_t key);
100 void forEach(
const std::function<
void(
size_t, boost::shared_ptr<Domain>&)>& executeMe);
116 std::map<size_t, boost::weak_ptr<Domain>>
_domains;
123 boost::shared_ptr<BackendType> backend,
size_t domainId,
bool activate,
RegisterPath name,
size_t numberOfWords,
127 auto domain =
_domains[domainId].lock();
128 boost::shared_ptr<DomainImpl<BackendSpecificDataType>> domainImpl;
130 bool domainCreated{
false};
132 domainImpl = boost::dynamic_pointer_cast<DomainImpl<BackendSpecificDataType>>(domain);
137 domainCreated =
true;
138 domainImpl = boost::make_shared<DomainImpl<BackendSpecificDataType>>(backend, domainId);
151 auto newSubscriber = domainImpl->template subscribe<UserDataType>(name, numberOfWords, wordOffsetInRegister, flags);
155 if(domainCreated && activate) {
156 auto subscriptionDone = backend->activateSubscription(domainId, domainImpl);
159 subscriptionDone.wait();
160 auto [value, version] = backend->template getAsyncDomainInitialValue<BackendSpecificDataType>(domainId);
161 domainImpl->activate(value, version);
164 return newSubscriber;
The DomainsContainer has a container with Domains and is performing actions on all of them.
std::map< size_t, boost::weak_ptr< Domain > > _domains
boost::shared_ptr< AsyncNDRegisterAccessor< UserDataType > > subscribe(boost::shared_ptr< BackendType > backend, size_t domainId, bool activate, RegisterPath name, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags)
Get an accessor from a particular domain.
std::atomic_bool _isSendingExceptions
cppext::future_queue< std::string > _startExceptionDistribution
void sendExceptions(const std::string &exceptionMessage)
Request the sending of exceptions.
void forEach(const std::function< void(size_t, boost::shared_ptr< Domain > &)> &executeMe)
Iterate all Domains under the container lock.
boost::shared_ptr< Domain > getDomain(size_t key)
Return the shared pointer to the Domain for a key.
std::mutex _threadCreationMutex
void distributeExceptions()
Endless loop executed in the thread.
std::thread _distributorThread
std::atomic_bool _threadIsRunning
bool isSendingExceptions()
Check whether an exception distribution is started and not completed yet.