CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
value_task.h
1
2#pragma once
3
4#include <system/object.h>
5#include <system/iequatable.h>
6#include <system/threading/tasks/async.h>
7#include <system/threading/tasks/task.h>
8
9namespace System { namespace Runtime { namespace CompilerServices {
10class ValueTaskAwaiter;
11class ConfiguredValueTaskAwaitable;
12}}
13
14namespace Threading { namespace Tasks {
15
17class ASPOSECPP_SHARED_CLASS ValueTask final : public IEquatable<ValueTask>, public System::Details::BoxableObjectBase
18{
19 using ThisType = ValueTask;
20 using BaseType = Object;
21
22public:
26 ASPOSECPP_SHARED_API ValueTask();
30 ASPOSECPP_SHARED_API ValueTask(const TaskPtr& task);
31
34 ASPOSECPP_SHARED_API bool get_IsFaulted() const;
37 ASPOSECPP_SHARED_API bool get_IsCompletedSuccessfully() const;
40 ASPOSECPP_SHARED_API bool get_IsCompleted() const;
43 ASPOSECPP_SHARED_API bool get_IsCanceled() const;
44
47 ASPOSECPP_SHARED_API TaskPtr AsTask() const;
53 ConfigureAwait(bool continueOnCapturedContext) const;
57 ASPOSECPP_SHARED_API bool Equals(ValueTask other) override;
61 ASPOSECPP_SHARED_API bool Equals(System::SharedPtr<System::Object> obj) override;
66
70 ASPOSECPP_SHARED_API bool operator==(const ValueTask& other) const;
74 ASPOSECPP_SHARED_API bool operator!=(const ValueTask& other) const;
75
76private:
79
81 TaskPtr m_task;
82};
83
84}} // namespace Threading::Tasks
85
86namespace Runtime { namespace CompilerServices {
87
88class ASPOSECPP_SHARED_CLASS ValueTaskAwaiter
89{
90public:
92
93 ASPOSECPP_SHARED_API bool get_IsCompleted() const;
94
95 ASPOSECPP_SHARED_API void OnCompleted(const Action<>& continuation);
96 ASPOSECPP_SHARED_API void GetResult() const;
97
98 bool continueOnCapturedContext = false;
99
100private:
102};
103
104class ASPOSECPP_SHARED_CLASS ConfiguredValueTaskAwaitable
105{
106public:
107 ASPOSECPP_SHARED_API ConfiguredValueTaskAwaitable(const Threading::Tasks::ValueTask& task, bool continueOnCapturedContext);
108
110
111private:
113 bool m_continueOnCapturedContext;
114};
115
116}} // namespace Runtime::CompilerServices
117
118ASPOSECPP_SHARED_API Threading::Tasks::ValueTask MakeValueAsync(const Details::AsyncFunction& fnc);
119
120} // namespace System
Defines a method that determines the equality of two objects. Objects of this class should only be al...
Definition: iequatable.h:16
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
Runtime::CompilerServices::ValueTaskAwaiter GetAwaiter() const
ConfiguredValueTaskAwaitable(const Threading::Tasks::ValueTask &task, bool continueOnCapturedContext)
void OnCompleted(const Action<> &continuation)
ValueTaskAwaiter(Threading::Tasks::ValueTask task)
Provides an awaitable result of an asynchronous operation.
Definition: value_task.h:18
ValueTask(const TaskPtr &task)
Constructs a ValueTask from a shared pointer to a Task.
Runtime::CompilerServices::ValueTaskAwaiter GetAwaiter() const
Gets an awaiter for this task to support await expressions.
Runtime::CompilerServices::ConfiguredValueTaskAwaitable ConfigureAwait(bool continueOnCapturedContext) const
Configures an awaiter for this task.
bool get_IsCanceled() const
Gets a value indicating whether the task completed due to being canceled.
bool operator!=(const ValueTask &other) const
Inequality operator for ValueTask.
bool get_IsCompletedSuccessfully() const
Gets a value indicating whether the task completed successfully.
ValueTask()
Constructs an empty, uninitialized ValueTask.
bool Equals(ValueTask other) override
Determines whether this instance equals another ValueTask instance.
bool get_IsFaulted() const
Gets a value indicating whether the task completed due to an unhandled exception.
bool Equals(System::SharedPtr< System::Object > obj) override
Determines whether this instance equals another object.
bool operator==(const ValueTask &other) const
Equality operator for ValueTask.
bool get_IsCompleted() const
Gets a value indicating whether the task has completed.
TaskPtr AsTask() const
Converts this ValueTask to a shared pointer to Task.
Definition: db_command.h:9
MulticastDelegate< void(Args...)> Action
Delegate type that references methods that have no return value.
Definition: action.h:40
Threading::Tasks::ResultValueTask< T > MakeValueAsync(const Details::ResultAsyncFunction< T > &fnc)
Definition: result_value_task.h:213