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" 35 class future<
void>
final :
private internal::future_base<
void> {
37 using shared_state_type =
38 typename internal::future_base<
void>::shared_state_type;
71 std::shared_ptr<shared_state_type> tmp;
72 tmp.swap(shared_state_);
76 using future_base::is_ready;
77 using future_base::valid;
78 using future_base::wait;
79 using future_base::wait_for;
80 using future_base::wait_until;
101 using requires_unwrap_t =
102 typename internal::then_helper<F,
void>::requires_unwrap_t;
103 return then_impl(std::forward<F>(func), requires_unwrap_t{});
106 explicit future(std::shared_ptr<shared_state_type> state)
107 : future_base<
void>(std::move(state)) {}
111 template <
typename F>
112 typename internal::then_helper<F,
void>::future_t then_impl(F&& functor,
116 template <
typename F>
117 typename internal::then_helper<F,
void>::future_t then_impl(F&& functor,
120 template <
typename U>
128 class promise<
void>
final :
private internal::promise_base<
void> {
134 promise(promise&& rhs)
noexcept =
default;
139 promise tmp
(std::move(rhs)
);
153 promise(promise
const&) =
delete;
154 promise&
operator=(promise
const&) =
delete;
157 void swap(promise& other)
noexcept {
158 std::swap(shared_state_, other.shared_state_);
165 shared_state_type::mark_retrieved(shared_state_);
178 if (!shared_state_) {
179 internal::ThrowFutureError(std::future_errc::no_state,
__func__);
181 shared_state_->set_value();
184 using promise_base<
void>::set_exception;
#define GOOGLE_CLOUD_CPP_NS
Contains all the Google Cloud C++ Library APIs.
promise(promise &&rhs) noexcept=default
Constructs a new promise and transfer any shared state from rhs.
void get()
Waits until the shared state becomes ready, then retrieves the value stored in the shared state...
void swap(promise &other) noexcept
Swaps the shared state in *this with rhs.
promise & operator=(promise &&rhs) noexcept
Abandons the shared state in *this, if any, and transfers the shared state from rhs.
promise()=default
Creates a promise with an unsatisfied shared state.
internal::then_helper< F, void >::future_t then(F &&func)
Attach a continuation to the future.
promise(promise const &)=delete
void set_value()
Satisfies the shared state.
future< void > get_future()
Creates the future<void> using the same shared state as *this.
future(std::shared_ptr< shared_state_type > state)
promise & operator=(promise const &)=delete
future(future< future< void >> &&rhs) noexcept(false)
Creates a new future that unwraps rhs.
~promise()=default
Abandons any shared state.