20 class task<void> :
public xtd::threading::tasks::basic_task<> {
25 std::coroutine_handle<promise_type> self;
27 auto final_suspend()
noexcept {
28 struct final_awaiter {
31 bool await_ready()
noexcept {
return false;}
32 void await_resume()
noexcept {}
33 void await_suspend(std::coroutine_handle<promise_type> handle)
noexcept {
34 promise.task_->start();
35 promise.self.destroy();
38 return final_awaiter {*
this};
42 self = std::coroutine_handle<promise_type>::from_promise(*
this);
45 std::suspend_never initial_suspend() {
return {};}
47 void unhandled_exception() {exception = task_->xtd::threading::tasks::basic_task<>::data_->exception;}
53 bool await_ready()
const noexcept {
return task_.is_completed();}
54 void await_resume() {
if (task_.is_faulted()) task_.rethrow_exception();}
55 void await_suspend(std::coroutine_handle<> handle) {task_.continue_with([handle] {handle.resume();});}
60 task(task&&) =
default;
61 task(
const task&) =
default;
62 auto operator=(task&&) -> task& =
default;
63 auto operator=(
const task&) -> task& =
default;
76 task(
const std::function<
void()>&
action) : basic_task<> {
action} {}
77 task(
const std::function<
void()>&
action,
const xtd::threading::cancellation_token& cancellation_token) : basic_task<> {
action, cancellation_token} {}
78 task(
const std::function<
void(
const xtd::any_object&)>&
action,
const xtd::any_object& state) : basic_task<> {
action, state} {}
79 task(
const std::function<
void(
const xtd::any_object&)>&
action,
const xtd::any_object& state,
const xtd::threading::cancellation_token& cancellation_token) : basic_task<> {
action, state, cancellation_token} {}
85 [[nodiscard]]
static auto from_result() -> task {
88 t.basic_task<>::data_->end_event.set();
96 auto operator co_await()
noexcept {
return awaiter {*
this};}
Contains xtd::threading::tasks::basic_task <> class.
Represent a polymorphic wrapper capable of holding any type.
Definition any_object.hpp:29
Represents an exception whose state is captured at a certain point in code.
Definition exception_dispatch_info.hpp:32
Propagates notification that operations should be canceled.
Definition cancellation_token.hpp:39
Represents an asynchronous operation.
Definition task_result.hpp:20
@ ran_to_completion
The task completed execution successfully.
Definition task_status.hpp:35
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
ptr< type_t > new_ptr(args_t &&... args)
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
delegate< void(arguments_t...)> action
Represents a xtd::delegate that has variable parameters and does not return a value.
Definition action.hpp:20
@ t
The T key.
Definition console_key.hpp:126
The xtd::threading::tasks namespace provides types that simplify the work of writing concurrent and a...
Definition itask.hpp:14
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
Definition task_result.hpp:50
Contains xtd::threading::tasks::task <result_t> class.