ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
AsyncAccessorManager.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
5
6namespace ChimeraTK::async {
7
8 thread_local AsyncAccessorManager* AsyncAccessorManager::_isHoldingDomainLock{nullptr};
9
10 /********************************************************************************************************************/
13 // The destructor of the AsyncVariable implementation must do all necessary clean-up
14 _asyncVariables.erase(id);
15 }
16 /********************************************************************************************************************/
18 if(_isHoldingDomainLock == this) {
19 _delayedUnsubscriptions.push_back(id);
20 }
21 else {
22 auto domainLock = _asyncDomain->getDomainLock();
24 }
25 }
26
27 /********************************************************************************************************************/
28 void AsyncAccessorManager::sendException(const std::exception_ptr& e) {
30 assert(_delayedUnsubscriptions.empty());
31
32 for(auto& var : _asyncVariables) {
33 var.second->sendException(e);
34 }
35 _isHoldingDomainLock = nullptr;
36
37 for(auto id : _delayedUnsubscriptions) {
39 }
41 }
42
43} // namespace ChimeraTK::async
Simple class holding a unique ID for a TransferElement.
std::map< TransferElementID, std::unique_ptr< AsyncVariable > > _asyncVariables
void unsubscribeImpl(TransferElementID id)
Internal helper function to avoid code duplication.
void sendException(const std::exception_ptr &e)
Send an exception to all accessors.
void unsubscribe(TransferElementID id)
This function must only be called from the destructor of the AsyncNDRegisterAccessor which is created...
std::list< TransferElementID > _delayedUnsubscriptions
If an unsubscription request is coming in while iterating the _asyncVariables container,...
static thread_local AsyncAccessorManager * _isHoldingDomainLock
We have to remember that we are holding the domain lock before we lock a weak pointer to an AsyncNDRe...
virtual void asyncVariableMapChanged(TransferElementID)
This virtual function lets derived classes react on subscribe / unsubscribe.