xtd 0.2.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 cancellation_token(const cancellation_token&) = default;
65 auto operator=(cancellation_token&&) -> cancellation_token& = default;
66 auto operator=(const cancellation_token&) -> cancellation_token& = default;
68
70
74 [[nodiscard]] auto can_be_canceled() const noexcept -> bool;
75
80 [[nodiscard]] auto is_cancellation_requested() const noexcept -> bool;
81
84 [[nodiscard]] auto wait_handle() noexcept -> threading::wait_handle&;
86
88
93 [[nodiscard]] auto equals(const object& obj) const noexcept -> bool override;
97 [[nodiscard]] auto equals(const cancellation_token& other) const noexcept -> bool override;
98
101 [[nodiscard]] auto get_hash_code() const noexcept -> xtd::size override;
102
112
113 private:
114 friend class cancellation_token_source;
115 explicit cancellation_token(cancellation_token_source& token_source);
116
117 struct data {
118 bool canceled = false;
119 cancellation_token_source* token_source = nullptr;
121 };
123
124 };
125 }
126}
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 get_hash_code() const noexcept -> xtd::size override
Serves as a hash function for a particular type.
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 equals(const object &obj) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
Represents a thread synchronization event that, when signaled, must be reset manually....
Definition manual_reset_event.hpp:35
Contains core_export_ keyword.
#define core_export_
Define shared library export.
Definition core_export.hpp:13
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
sptr< type_t > new_sptr(args_t &&... args)
xtd::new_sptr operator creates a xtd::sptr object.
Definition new_sptr.hpp:24
@ other
The operating system is other.
Definition platform_id.hpp:60
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
Contains xtd::object class.
Contains xtd fundamental types.