Wait until the asynchronous result associated with an instance of std::future
is ready, or until a specified time period has elapsed.
template<typename Rep,typename Period> future_status wait_for( std::chrono::duration<Rep,Period> const& relative_time);
- Preconditions:
this->valid()would returntrue.- Effects:
If the asynchronous result associated with
*thiscontains a deferred function arising from a call tostd::asyncthat has not yet started execution, returns immediately without blocking. Otherwise blocks until the asynchronous result associated with*thisis ready or the time period specified byrelative_timehas elapsed.- Returns:
std::future_status::deferredif the asynchronous result associated with*thiscontains a deferred function arising from a call tostd::asyncthat has not yet started execution,std::future_status::readyif the asynchronous result associated with*thisis ready,std::future_status::timeoutif the time period specified byrelative_timehas elapsed.- Note:
The thread may be blocked for longer than the specified duration. Where possible, the elapsed time is determined by a steady clock.
- Throws:
Nothing.
Header
#include <future>