The std::future
class template provides a means of waiting for an asynchronous result from
another thread, in conjunction with the std::promise and std::packaged_task class templates
and the std::async
function template which can be used to provide that asynchronous result.
Only one std::future
instance references any given asynchronous result at any time.
Instances of std::future
are MoveConstructible and
MoveAssignable, but not
CopyConstructible or CopyAssignable.
template<typename ResultType> class future { public: future(); future(future&&); future& operator=(future&&); ~future(); future(future const&) = delete; future& operator=(future const&) = delete; shared_future<ResultType> share(); bool valid() const; bool is_ready() const; bool has_exception() const; bool has_value() const; see description get(); void wait(); template<typename Rep,typename Period> future_status wait_for( std::chrono::duration<Rep,Period> const& relative_time); template<typename Clock,typename Duration> future_status wait_until( std::chrono::time_point<Clock,Duration> const& absolute_time); };
Header
#include <future>