xtd 1.0.0
Loading...
Searching...
No Matches
cancellation_token.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../core_export.hpp"
6#include "../iequatable.hpp"
7#include "../object.hpp"
8#include "../types.hpp"
10
12namespace xtd {
14 namespace threading {
18
39 class core_export_ cancellation_token : public object, public iequatable<cancellation_token> {
40 struct data;
41 public:
43
50
52
58 cancellation_token(bool canceled);
60
64
66
70 [[nodiscard]] auto can_be_canceled() const noexcept -> bool;
71
76 [[nodiscard]] auto is_cancellation_requested() const noexcept -> bool;
77
80 [[nodiscard]] auto wait_handle() noexcept -> threading::wait_handle&;
82
84
89 [[nodiscard]] auto equals(const object& obj) const noexcept -> bool override;
93 [[nodiscard]] auto equals(const cancellation_token& other) const noexcept -> bool override;
94
97 [[nodiscard]] auto get_hash_code() const noexcept -> xtd::usize override;
98
108
109 private:
110 friend class cancellation_token_source;
111 explicit cancellation_token(const cancellation_token_source& token_source);
112 auto cancel() -> void;
113
114 xtd::sptr<data> data_;
115
116 };
117 }
118}
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
object()=default
Create a new instance of the ultimate base class object.
Signals to a xtd::threading::cancellation_token that it should be canceled.
Definition cancellation_token_source.hpp:38
auto can_be_canceled() const noexcept -> bool
Gets whether this token is capable of being in the canceled state.
auto throw_if_cancellation_requested() const -> void
Throws a xtd::operation_canceled_exception if this token has had cancellation requested.
cancellation_token(bool canceled)
Initializes the xtd::threading::cancellation_token.
static cancellation_token none
Represents an empty xtd::threading::cancellation_token value.
Definition cancellation_token.hpp:48
auto is_cancellation_requested() const noexcept -> bool
Gets whether cancellation has been requested for this token.
auto wait_handle() noexcept -> threading::wait_handle &
Gets a xtd::threading::wait_handle that is signaled when the token is canceled.
auto get_hash_code() const noexcept -> xtd::usize override
Serves as a hash function for a particular type.
auto equals(const object &obj) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
Contains core_export_ keyword.
#define core_export_
Define shared library export.
Definition core_export.hpp:13
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
Contains xtd::iequatable interface.
Contains xtd::threading::manual_reset_event exception.
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
constexpr auto data() const noexcept -> const_pointer
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:197
Contains xtd::object class.
Contains xtd fundamental types.