Iros
 
Loading...
Searching...
No Matches
in_place_stop_token.h
Go to the documentation of this file.
1#pragma once
2
4
5namespace di::sync {
6class InPlaceStopToken {
7private:
8 friend class InPlaceStopSource;
9
10 template<typename>
11 friend class InPlaceStopCallback;
12
13 explicit InPlaceStopToken(InPlaceStopSource const* source) : m_source(source) {}
14
15public:
16 template<typename Callback>
18
19 InPlaceStopToken() = default;
20 ~InPlaceStopToken() = default;
21
22 [[nodiscard]] auto stop_requested() const -> bool { return !!m_source && m_source->stop_requested(); }
23 [[nodiscard]] auto stop_possible() const -> bool { return !!m_source; }
24
25 [[nodiscard]] auto operator==(InPlaceStopToken const&) const -> bool = default;
26
27private:
28 InPlaceStopSource const* m_source { nullptr };
29};
30
32 return InPlaceStopToken { this };
33}
34}
auto get_stop_token() const -> InPlaceStopToken
Definition in_place_stop_token.h:31
Definition in_place_stop_token.h:6
InPlaceStopCallback< Callback > CallbackType
Definition in_place_stop_token.h:17
friend class InPlaceStopCallback
Definition in_place_stop_token.h:11
friend class InPlaceStopSource
Definition in_place_stop_token.h:8
auto stop_requested() const -> bool
Definition in_place_stop_token.h:22
auto stop_possible() const -> bool
Definition in_place_stop_token.h:23
auto operator==(InPlaceStopToken const &) const -> bool=default
Definition atomic.h:12