CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
cancellation_token_source.h
1
3#pragma once
4
5#include <system/idisposable.h>
6#include <system/action.h>
7#include <map>
8
9namespace System { namespace Threading {
10
11class CancellationToken;
12
16class ASPOSECPP_SHARED_CLASS CancellationTokenSource : public IDisposable
17{
18public:
21 ASPOSECPP_SHARED_API CancellationTokenSource();
22
25 bool get_IsCancellationRequested() const {return m_canceled;}
28 ASPOSECPP_SHARED_API CancellationToken get_Token() const;
29
35 static ASPOSECPP_SHARED_API SharedPtr<CancellationTokenSource>
37
42 ASPOSECPP_SHARED_API void Cancel();
43
47 ASPOSECPP_SHARED_API void Dispose() override;
48
49private:
50 friend CancellationToken;
52
54 ASPOSECPP_SHARED_API int32_t RegisterCallback(const Action<>&);
56 ASPOSECPP_SHARED_API void UnregisterCallback(int32_t);
57
59 bool m_canceled;
61 std::map<int32_t, Action<>> m_callbacks;
62};
63
64}} // System::Threading
Defines method that releases resources owned by the current object. Objects of this class should only...
Definition: idisposable.h:30
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Propagates notification that operations should be canceled. This class provides a mechanism for coope...
Definition: cancellation_token.h:43
Represents a registration for a cancellation token callback.
Definition: cancellation_token.h:19
A cancellation token source that can be used to trigger cancellation notifications.
Definition: cancellation_token_source.h:17
static SharedPtr< CancellationTokenSource > CreateLinkedTokenSource(const CancellationToken &token1, const CancellationToken &token2)
Creates a linked token source that cancels when any of the provided tokens cancel.
void Dispose() override
Releases all resources used by the CancellationTokenSource.
bool get_IsCancellationRequested() const
Gets whether cancellation has been requested.
Definition: cancellation_token_source.h:25
CancellationTokenSource()
Constructs a new CancellationTokenSource.
CancellationToken get_Token() const
Gets the cancellation token associated with this source.
void Cancel()
Communicates a request for cancellation.
Definition: db_command.h:9
MulticastDelegate< void(Args...)> Action
Delegate type that references methods that have no return value.
Definition: action.h:40