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

Store an exception in the asynchronous result associated with *this.

void set_exception(std::exception_ptr e);

Preconditions:

*this has an associated asynchronous result. (bool)e is true.

Effects:

Store e in the asynchronous result associated with *this.

Postconditions:

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

Throws:

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.

Synchronization:

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

Header

#include <experimental/future>

See Also