5#include <system/idisposable.h>
6#include <system/threading/tasks/task_status.h>
7#include <system/threading/cancellation_token.h>
8#include <system/action.h>
13namespace Threading {
namespace Tasks {
16namespace Runtime {
namespace CompilerServices {
18class ConfiguredTaskAwaitable;
21namespace Threading {
namespace Tasks {
66 int32_t
get_Id()
const {
return m_id;}
98 ASPOSECPP_SHARED_API
void Start();
110 ASPOSECPP_SHARED_API
void Wait();
155 std::exception_ptr m_exception;
163 std::list<Action<>> m_continuations;
165 static int32_t m_next_id;
170namespace Runtime {
namespace CompilerServices {
181 bool continueOnCapturedContext =
false;
195 bool m_continueOnCapturedContext;
Defines method that releases resources owned by the current object. Objects of this class should only...
Definition: idisposable.h:30
Forward declaration.
Definition: nullable.h:74
void OnCompleted(const Action<> &continuation)
TaskAwaiter(const TaskPtr &task)
Definition: task.h:175
bool get_IsCompleted() const
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 an asynchronous operation that can be awaited and composed with other tasks.
Definition: task.h:27
bool get_IsFaulted() const
Gets whether the task completed due to an unhandled exception.
Definition: task.h:72
void AddContinuation(const Action<> &continuation)
Adds a continuation action to be executed upon completion.
void set_Function(const FunctionT &fnc)
Sets the internal function to execute.
Definition: task.h:123
bool get_IsCanceled() const
Gets whether the task completed due to cancellation.
Definition: task.h:60
void Start()
Starts the task execution using the default scheduler.
int32_t get_Id() const
Gets the ID for task.
Definition: task.h:66
void Wait()
Waits for the task to complete.
void Dispose() override
Releases resources associated with the task.
Runtime::CompilerServices::TaskAwaiter GetAwaiter() const
Gets an awaiter for this task for use with Await.
void RunSynchronously()
Runs the task synchronously on the current thread.
Task()
Internal constructor for creating uninitialized tasks.
void Execute()
Executes the task's function.
Runtime::CompilerServices::ConfiguredTaskAwaitable ConfigureAwait(bool continueOnCapturedContext) const
Configures how awaits on this task should behave regarding context capture.
Task(const Action< SharedPtr< Object > > &action, const SharedPtr< Object > &state, const CancellationToken &cancellationToken)
Constructs a Task with stateful action, state, and cancellation token.
void Wait(const CancellationToken &cancellationToken)
Waits for the task to complete with cancellation support.
TaskStatus get_Status() const
Gets the current status of the task.
Definition: task.h:63
void Complete()
Marks the task as completed and finishes task.
TaskPtr ContinueWith(const Action< TaskPtr > &continuationAction)
Creates a continuation that executes when the task completes.
bool get_IsCompleted() const
Gets whether the task has completed.
TaskScheduler * get_Scheduler() const
Gets the scheduler associated with this task.
Definition: task.h:127
Task(const Action<> &action)
Constructs a Task with an action to execute.
void ExecuteContinuations()
Executes all registered continuations.
void Activate(TaskScheduler *=nullptr)
Activates the task for execution on a scheduler.
static Nullable< int32_t > get_CurrentId()
static const TaskPtr & get_CompletedTask()
Gets a completed task (singleton)
Task(const Action<> &action, const CancellationToken &cancellationToken)
Constructs a Task with an action and cancellation token.
Task(const Action< SharedPtr< Object > > &action, const SharedPtr< Object > &state)
Constructs a Task with a stateful action and state object.
void ContinueWithCore(const TaskPtr &continuationTask)
Internal implementation for adding continuations.
const SharedPtr< Object > & get_AsyncState() const
Gets the user-defined state object associated with the task.
Definition: task.h:69
void Start(const SharedPtr< TaskScheduler > &scheduler)
Starts the task execution using the specified scheduler.
std::function< void()> FunctionT
Internal implementation. Not for user code.
Definition: task.h:118
void RunSynchronously(const SharedPtr< TaskScheduler > &scheduler)
Runs the task synchronously using the specified scheduler.
void Finish()
Finalizes task completion and executes continuations.
void set_Status(TaskStatus status)
Sets the task status.
Represents an object that handles the low-level work of queuing tasks onto threads.
Definition: task_scheduler.h:11
TaskStatus
Definition: task_status.h:8
Definition: db_command.h:9
MulticastDelegate< void(Args...)> Action
Delegate type that references methods that have no return value.
Definition: action.h:40