Documentation Home >> Headers >> <jss/experimental_future.hpp> Header >> std::experimental::promise >> std::experimental::promise::set_value Member function

Store a value in the asynchronous result associated with *this.

void promise<void>::set_value();
void promise<R&>::set_value(R& r);
void promise<R>::set_value(R const& r);
void promise<R>::set_value(R&& r);


*this has an associated asynchronous result.


Store r in the asynchronous result associated with *this if ResultType is not void.


The asynchronous result associated with *this is ready with a stored value. Any threads blocked waiting for the asynchronous result are unblocked.


An exception of type std::future_error with an error code of std::future_errc::promise_already_satisfied if the asynchronous result already has a stored value or exception. Any exceptions thrown by the copy-constructor or move-constructor of r.


Multiple concurrent calls to set_value(), set_value_at_thread_exit(), set_exception() and set_exception_at_thread_exit() are serialized. A successful call to set_value() happens-before a call to std::experimental::future<ResultType>::get() or std::experimental::shared_future<ResultType>::get() which retrieves the value stored.


#include <experimental/future>

See Also