xtd 0.2.0
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"
9#include "wait_handle.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& operator=(const cancellation_token& cancellation_token) = default;
67
69
73 bool can_be_canceled() const noexcept;
74
79 bool is_cancellation_requested() const noexcept;
80
85
87
92 bool equals(const object& obj) const noexcept override;
96 bool equals(const cancellation_token& other) const noexcept override;
97
100 xtd::size get_hash_code() const noexcept override;
101
111
112 private:
113 friend class cancellation_token_source;
114 explicit cancellation_token(cancellation_token_source& token_source);
115
116 bool canceled_ = false;
117 cancellation_token_source* token_source_ = nullptr;
118 xtd::sptr<threading::wait_handle> wait_handle_;
119 };
120 }
121}
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
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
bool can_be_canceled() const noexcept
Gets whether this token is capable of being in the canceled state.
void throw_if_cancellation_requested() const
Throws a xtd::operation_canceled_exception if this token has had cancellation requested.
cancellation_token(bool canceled)
Initializes the xtd::threading::cancellation_token.
threading::wait_handle & wait_handle() noexcept
Gets a xtd::threading::wait_handle that is signaled when the token is canceled.
static cancellation_token none
Represents an empty xtd::threading::cancellation_token value.
Definition cancellation_token.hpp:48
bool equals(const object &obj) const noexcept override
Determines whether the specified object is equal to the current object.
xtd::size get_hash_code() const noexcept override
Serves as a hash function for a particular type.
bool is_cancellation_requested() const noexcept
Gets whether cancellation has been requested for this token.
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
@ other
The operating system is other.
Definition platform_id.hpp:58
Contains xtd::iequatable interface.
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 const_pointer data() const noexcept
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:201
Contains xtd::object class.
Contains xtd fundamental types.
Contains xtd::threading::wait_handle class.