14 template<
class result_t =
void>
20 std::coroutine_handle<promise_type> self;
22 auto final_suspend()
noexcept {
23 struct final_awaiter {
26 bool await_ready()
noexcept {
return false;}
27 void await_resume()
noexcept {}
28 void await_suspend(std::coroutine_handle<promise_type> handle)
noexcept {
29 promise.task->start();
30 promise.self.destroy();
33 return final_awaiter {*
this};
37 self = std::coroutine_handle<promise_type>::from_promise(*
this);
40 std::suspend_never initial_suspend() {
return {};}
42 void unhandled_exception() {}
48 bool await_ready()
const noexcept {
return task.is_completed();}
49 void await_suspend(std::coroutine_handle<> handle) {task.continue_with([handle] {handle.resume();});}
50 void await_resume() {
if (task.is_faulted()) task.rethrow_exception();}
55 wtask(wtask&&) =
default;
56 wtask(
const wtask&) =
default;
57 auto operator=(wtask&&) -> wtask& =
default;
58 auto operator=(
const wtask&) -> wtask& =
default;
70 wtask(
const std::function<result_t()>&
func) : task<result_t>(
func) {}
72 wtask(
const std::function<result_t(
const xtd::any_object&)>&
func,
const xtd::any_object& state) : task<result_t>(
func, state) {}
74 ~wtask() {task<result_t>::wait();}
80 auto operator co_await()
noexcept {
return awaiter {*
this};}
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
Contains xtd::func delegate.
xtd::delegate< result_t(arguments_t... arguments)> func
Represents a delegate that has variables parameters and returns a value of the type specified by the ...
Definition func.hpp:27
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
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
Contains xtd::threading::tasks::task <result_t> class.