xtd 0.2.0
Loading...
Searching...
No Matches
cancellation_token.h
Go to the documentation of this file.
1
4#pragma once
5#include "../core_export.h"
6#include "../iequatable.h"
7#include "../object.h"
8#include "../types.h"
9#include "wait_handle.h"
10
12namespace xtd {
14 namespace threading {
16 class cancellation_token_source;
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
83 threading::wait_handle& wait_handle() noexcept;
85
87
89 using object::equals;
90 bool equals(const cancellation_token& other) const noexcept;
91
99 void throw_if_cancellation_requested() const;
101
102 private:
103 friend class cancellation_token_source;
104 explicit cancellation_token(cancellation_token_source& token_source);
105
106 bool canceled_ = false;
107 cancellation_token_source* token_source_ = nullptr;
108 xtd::sptr<threading::wait_handle> wait_handle_;
109 };
110 }
111}
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.h:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
Signals to a xtd::threading::cancellation_token that it should be canceled.
Definition cancellation_token_source.h:38
Propagates notification that operations should be canceled.
Definition cancellation_token.h:39
bool can_be_canceled() const noexcept
Gets whether this token is capable of being in the canceled state.
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.h:48
Encapsulates operating system specific objects that wait for exclusive access to shared resources.
Definition wait_handle.h:52
#define core_export_
Define shared library export.
Definition core_export.h:13
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.h:25
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::threading::wait_handle exception.