-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathget_stop_token.hpp
45 lines (36 loc) · 1.41 KB
/
get_stop_token.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// include/Beman/Execution26/detail/get_stop_token.hpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef INCLUDED_BEMAN_EXECUTION26_DETAIL_GET_STOP_TOKEN
#define INCLUDED_BEMAN_EXECUTION26_DETAIL_GET_STOP_TOKEN
#include <Beman/Execution26/detail/forwarding_query.hpp>
#include <Beman/Execution26/detail/never_stop_token.hpp>
#include <Beman/Execution26/detail/stoppable_token.hpp>
#include <utility>
// ----------------------------------------------------------------------------
namespace Beman::Execution26
{
struct get_stop_token_t
{
template <typename Object>
requires requires(Object&& object, get_stop_token_t const& tag)
{
{ ::std::as_const(object).query(tag) } noexcept -> ::Beman::Execution26::stoppable_token;
}
auto operator()(Object&& object) const noexcept
{
return ::std::as_const(object).query(*this);
}
template <typename Object>
auto operator()(Object&&) const noexcept -> ::Beman::Execution26::never_stop_token
{
return {};
}
constexpr auto query(::Beman::Execution26::forwarding_query_t const&) const noexcept -> bool
{
return true;
}
};
inline constexpr get_stop_token_t get_stop_token{};
}
// ----------------------------------------------------------------------------
#endif