15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FUTURE_VOID_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FUTURE_VOID_H
23 #include "google/cloud/internal/future_base.h"
24 #include "google/cloud/internal/future_fwd.h"
25 #include "google/cloud/internal/future_impl.h"
26 #include "google/cloud/internal/future_then_meta.h"
27 #include "google/cloud/version.h"
36 class future<
void>
final :
private internal::future_base<
void> {
38 using shared_state_type =
39 typename internal::future_base<
void>::shared_state_type;
80 std::shared_ptr<shared_state_type> tmp;
81 tmp.swap(shared_state_);
85 using future_base::cancel;
86 using future_base::is_ready;
87 using future_base::valid;
88 using future_base::wait;
89 using future_base::wait_for;
90 using future_base::wait_until;
108 template <
typename F>
111 using requires_unwrap_t =
112 typename internal::then_helper<F,
void>::requires_unwrap_t;
113 return then_impl(std::forward<F>(func), requires_unwrap_t{});
116 explicit future(std::shared_ptr<shared_state_type> state)
117 : future_base<
void>(std::move(state)) {}
121 template <
typename F>
122 typename internal::then_helper<F,
void>::future_t then_impl(F&& functor,
126 template <
typename F>
127 typename internal::then_helper<F,
void>::future_t then_impl(F&& functor,
130 template <
typename U>
133 friend struct internal::CoroutineSupport;
140 class promise<
void>
final :
private internal::promise_base<
void> {
146 explicit promise(std::function<
void()> cancellation_callback)
147 : promise_base(std::move(cancellation_callback)) {}
150 explicit promise(null_promise_t x) : promise_base(std::move(x)) {}
158 promise tmp
(std::move(rhs)
);
176 void swap(promise& other)
noexcept {
177 std::swap(shared_state_, other.shared_state_);
184 shared_state_type::mark_retrieved(shared_state_);
197 if (!shared_state_) {
198 internal::ThrowFutureError(std::future_errc::no_state,
__func__);
200 shared_state_->set_value();
203 using promise_base<
void>::set_exception;