Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
SyncExecutionContext.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2024, the clio developers.
5
6 Permission to use, copy, modify, and distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#pragma once
21
22#include "util/async/context/BasicExecutionContext.hpp"
23#include "util/async/context/SystemExecutionContext.hpp"
24#include "util/async/context/impl/Cancellation.hpp"
25
26#include <boost/asio/error.hpp>
27
28#include <cstddef>
29
30namespace util::async {
31namespace impl {
32
34 struct Executor {
35 Executor(std::size_t)
36 {
37 }
38
39 void
40 stop() const noexcept
41 {
42 }
43
44 void
45 join() const noexcept
46 {
47 }
48 };
49
50 // Note: these types are not actually used but needed for compilation
51 struct Timer {};
52 struct Strand {
53 struct Executor {};
54 struct Timer {};
55 };
56
57 Executor executor;
58
59 void
60 stop() const noexcept
61 {
62 executor.stop();
63 }
64
65 void
66 join() const noexcept
67 {
68 executor.join();
69 }
70
71 Executor&
72 getExecutor()
73 {
74 return executor;
75 }
76
77 [[nodiscard]] Strand
78 makeStrand() noexcept // NOLINT(readability-convert-member-functions-to-static)
79 {
80 return {};
81 }
82};
83
85 template <typename CtxType>
86 [[nodiscard]] static constexpr auto&
87 getContext([[maybe_unused]] CtxType& self) noexcept
88 {
90 }
91};
92
93} // namespace impl
94
108
109} // namespace util::async
A highly configurable execution context.
Definition BasicExecutionContext.hpp:132
static auto & instance()
Get the instance of the system execution context.
Definition SystemExecutionContext.hpp:40
Definition Cancellation.hpp:102
This namespace implements an async framework built on top of execution contexts.
Definition AnyExecutionContext.hpp:36
Definition SyncExecutionContext.hpp:34
Definition SyncExecutionContext.hpp:53
Definition SyncExecutionContext.hpp:54
Definition SyncExecutionContext.hpp:52
Definition SyncExecutionContext.hpp:51
Definition SyncExecutionContext.hpp:33
Definition Execution.hpp:78
Definition SyncExecutionContext.hpp:84