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

Store an exception in the asynchronous result associated with *this without making that result ready until the current thread exits.

void set_exception_at_thread_exit(
    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. Schedule the associated asynchronous result to be made ready when the current thread exits.

Postconditions:

The asynchronous result associated with *this has a stored exception, but is not ready until the current thread exits. Threads blocked waiting for the asynchronous result will be unblocked when the current thread exits.

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(), set_value_at_thread_exit(), set_exception() and set_exception_at_thread_exit() are serialized. The completion of the thread that made a successful call to set_exception_at_thread_exit() 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