ChimeraTK-DeviceAccess  03.18.00
Domain.h
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 #pragma once
4 
5 #include <boost/enable_shared_from_this.hpp>
6 #include <boost/shared_ptr.hpp>
7 
8 #include <mutex>
9 
10 namespace ChimeraTK::async {
11 
25  class Domain : public boost::enable_shared_from_this<Domain> {
26  public:
27  virtual void sendException(const std::exception_ptr& e) noexcept = 0;
28  virtual void deactivate() = 0;
29  virtual ~Domain() = default;
30 
31  std::lock_guard<std::mutex> getDomainLock() { return std::lock_guard<std::mutex>{_mutex}; }
32 
33  protected:
34  // This mutex is protecting all members and all functions in Domain and DomainImpl
35  std::mutex _mutex;
36  bool _isActive{false};
37 
42  bool unsafeGetIsActive() const { return _isActive; }
43 
44  // The friend functions are only allowed to call unsafeGetIsActive(). They must not touch any of the
45  // internal variables directly.
46  friend class AsyncAccessorManager;
48  template<typename BackendSpecificDataType>
49  friend class SubDomain;
51 
52  template<typename SourceType>
54 
55  template<typename UserType>
57  };
58 } // namespace ChimeraTK::async
ChimeraTK::async::Domain::~Domain
virtual ~Domain()=default
ChimeraTK::async::AsyncNDRegisterAccessor
The AsyncNDRegisterAccessor implements a data transport queue with typed data as continuation of the ...
Definition: AsyncNDRegisterAccessor.h:23
ChimeraTK::async::AsyncAccessorManager
The AsyncAccessorManager has three main functionalities:
Definition: AsyncAccessorManager.h:69
ChimeraTK::async::SubDomain
Send backend-specific asynchronous data to different distributors:
Definition: MuxedInterruptDistributor.h:23
ChimeraTK::async
Definition: design_AsyncNDRegisterAcessor_and_NumericAddressedBackend.dox:1
ChimeraTK::async::Domain::deactivate
virtual void deactivate()=0
ChimeraTK::async::SourceTypedAsyncAccessorManager
Definition: AsyncAccessorManager.h:135
ChimeraTK::async::Domain::_mutex
std::mutex _mutex
Definition: Domain.h:35
ChimeraTK::async::TriggeredPollDistributor
The TriggeredPollDistributor has std::nullptr_t source data type and is polling the data for the Asyn...
Definition: TriggeredPollDistributor.h:17
ChimeraTK::async::Domain::sendException
virtual void sendException(const std::exception_ptr &e) noexcept=0
ChimeraTK::async::MuxedInterruptDistributor
Interface base class for interrupt controller handlers.
Definition: MuxedInterruptDistributor.h:56
ChimeraTK::async::Domain::unsafeGetIsActive
bool unsafeGetIsActive() const
Friend classes are allowed to read the _isActiveFlag without acquiring the mutex.
Definition: Domain.h:42
ChimeraTK::async::Domain::_isActive
bool _isActive
Definition: Domain.h:36
ChimeraTK::async::Domain
The Domain is the thread-safe entry point for each distribution tree.
Definition: Domain.h:25
ChimeraTK::async::Domain::getDomainLock
std::lock_guard< std::mutex > getDomainLock()
Definition: Domain.h:31