40 auto then(F&& f)
const {
42 task value_this = *
this;
44 value_this.
get().then([=](
auto t) {
45 nested_future->do_work(f, t);
48 return to_task(nested_future);
60 task value_this = *
this;
61 return to_task(future->then([=]() {
79 return future->get_state();
86 return future->get_exception();
107 template<
class Rep,
class Period>
108 bool wait_for(
const std::chrono::duration<Rep, Period>& timeout_duration)
const {
109 return future->wait_for(timeout_duration);
120 template<
class Clock,
class Duration>
121 bool wait_until(
const std::chrono::time_point<Clock, Duration>& timeout_time)
const {
122 return future->wait_until(timeout_time);
125#ifdef __cpp_lib_coroutine
129 task_awaiter(
const task<T>& t) : t(t) {}
130 task_awaiter(task<T>&& t) : t(std::move(t)) {}
132 bool await_ready() const noexcept {
133 return t.get_state() != task_state::pending;
136 void await_suspend(std::coroutine_handle<> cont)
const {
137 t.future->then([cont]{
165 task_awaiter
operator co_await()
const {
166 return task_awaiter(*
this);
171 std::shared_ptr<detail::task_future<T>> future;