Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
Outcome.hpp
1
#pragma once
2
3
#include "util/async/context/impl/Cancellation.hpp"
4
5
#include <concepts>
6
#include <future>
7
8
namespace
util::async
{
9
10
template
<
typename
RetType,
typename
StopSourceType>
11
class
StoppableOperation
;
12
13
namespace
impl {
14
15
template
<
typename
RetType>
16
class
BasicOperation
;
17
23
template
<
typename
RetType>
24
class
BasicOutcome {
25
protected
:
26
std::promise<RetType> promise_;
27
28
public
:
29
using
DataType = RetType;
30
31
BasicOutcome() =
default
;
32
BasicOutcome(BasicOutcome&&) =
default
;
33
34
BasicOutcome(BasicOutcome
const
&) =
delete
;
35
41
void
42
setValue
(std::convertible_to<RetType>
auto
&& val)
43
{
44
promise_.set_value(std::forward<
decltype
(val)>(val));
45
}
46
50
void
51
setValue
()
52
{
53
promise_.set_value({});
54
}
55
61
[[nodiscard]] std::future<RetType>
62
getStdFuture
()
63
{
64
return
promise_.get_future();
65
}
66
};
67
68
}
// namespace impl
69
75
template
<
typename
RetType>
76
class
Outcome
:
public
impl::BasicOutcome
<RetType> {
77
public
:
83
[[nodiscard]]
impl::BasicOperation<Outcome>
84
getOperation
()
85
{
86
return
impl::BasicOperation<Outcome>
{
this
};
87
}
88
};
89
96
template
<
typename
RetType,
typename
StopSourceType>
97
class
StoppableOutcome
:
public
impl::BasicOutcome
<RetType> {
98
private
:
99
StopSourceType stopSource_;
100
101
public
:
107
[[nodiscard]]
StoppableOperation<RetType, StopSourceType>
108
getOperation
()
109
{
110
return
StoppableOperation<RetType, StopSourceType>
{
this
};
111
}
112
118
[[nodiscard]] StopSourceType&
119
getStopSource
()
120
{
121
return
stopSource_;
122
}
123
};
124
125
}
// namespace util::async
util::async::Outcome
Unstoppable outcome.
Definition
Outcome.hpp:76
util::async::Outcome::getOperation
impl::BasicOperation< Outcome > getOperation()
Gets the unstoppable operation for this outcome.
Definition
Outcome.hpp:84
util::async::StoppableOperation
The future side of async operations that can be stopped.
Definition
Operation.hpp:151
util::async::StoppableOutcome
Stoppable outcome.
Definition
Outcome.hpp:97
util::async::StoppableOutcome::getOperation
StoppableOperation< RetType, StopSourceType > getOperation()
Gets the stoppable operation for this outcome.
Definition
Outcome.hpp:108
util::async::StoppableOutcome::getStopSource
StopSourceType & getStopSource()
Gets the stop source for this outcome.
Definition
Outcome.hpp:119
util::async::impl::BasicOperation
Definition
Operation.hpp:26
util::async::impl::BasicOutcome
Base for all promise side of async operations.
Definition
Outcome.hpp:24
util::async::impl::BasicOutcome::setValue
void setValue(std::convertible_to< RetType > auto &&val)
Sets the value on the inner promise.
Definition
Outcome.hpp:42
util::async::impl::BasicOutcome::getStdFuture
std::future< RetType > getStdFuture()
Get the future for the inner promise.
Definition
Outcome.hpp:62
util::async::impl::BasicOutcome::setValue
void setValue()
Sets the value channel for void operations.
Definition
Outcome.hpp:51
util::async
This namespace implements an async framework built on top of execution contexts.
Definition
AnyExecutionContext.hpp:18
src
util
async
Outcome.hpp
Generated by
1.17.0