FairMQ  1.4.33
C++ Message Queuing Library and Framework
AsioBase.h
1 /********************************************************************************
2  * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 #ifndef FAIR_MQ_SDK_ASIOBASE_H
10 #define FAIR_MQ_SDK_ASIOBASE_H
11 
12 #include <asio/any_io_executor.hpp>
13 #include <fairmq/sdk/Traits.h>
14 #include <memory>
15 #include <utility>
16 
17 namespace fair::mq::sdk
18 {
19 
20 using DefaultExecutor = asio::any_io_executor;
21 using DefaultAllocator = std::allocator<int>;
22 
33 template<typename Executor, typename Allocator>
34 class AsioBase
35 {
36  public:
38  using ExecutorType = Executor;
40  auto GetExecutor() const noexcept -> ExecutorType { return fExecutor; }
41 
43  using AllocatorType = Allocator;
45  auto GetAllocator() const noexcept -> AllocatorType { return fAllocator; }
46 
48  AsioBase() = delete;
49 
51  explicit AsioBase(Executor ex, Allocator alloc)
52  : fExecutor(std::move(ex))
53  , fAllocator(std::move(alloc))
54  {}
55 
57  AsioBase(const AsioBase&) = delete;
58  AsioBase& operator=(const AsioBase&) = delete;
59 
61  AsioBase(AsioBase&&) noexcept = default;
62  AsioBase& operator=(AsioBase&&) noexcept = default;
63 
64  ~AsioBase() = default;
65 
66  private:
67  ExecutorType fExecutor;
68  AllocatorType fAllocator;
69 };
70 
71 } // namespace fair::mq::sdk
72 
73 #endif /* FAIR_MQ_SDK_ASIOBASE_H */
fair::mq::sdk::AsioBase::AsioBase
AsioBase(Executor ex, Allocator alloc)
Construct with associated I/O executor.
Definition: AsioBase.h:57
fair::mq::sdk::AsioBase
Base for creating Asio-enabled I/O objects.
Definition: AsioBase.h:41
fair::mq::sdk::AsioBase::GetExecutor
auto GetExecutor() const noexcept -> ExecutorType
Get associated I/O executor.
Definition: AsioBase.h:46
fair::mq::sdk::AsioBase::GetAllocator
auto GetAllocator() const noexcept -> AllocatorType
Get associated default allocator.
Definition: AsioBase.h:51
fair::mq::sdk::AsioBase::AllocatorType
Allocator AllocatorType
Member type of associated default allocator.
Definition: AsioBase.h:49
fair::mq::sdk::AsioBase::AsioBase
AsioBase()=delete
NO default ctor.
fair::mq::sdk::AsioBase::ExecutorType
Executor ExecutorType
Member type of associated I/O executor.
Definition: AsioBase.h:44

privacy