< cpp‎ | thread‎ | future

template< class Clock, class Duration >
std::future_status wait_until( const std::chrono::time_point<Clock,Duration>& timeout_time ) const;
(since C++11)

wait_until waits for a result to become available. It blocks until specified timeout_time has been reached or the result becomes available, whichever comes first. The return value indicates why wait_until returned.

The clock tied to timeout_time is used, which means that adjustments of the clock are taken into account. Thus, the maximum duration of the block might differ from timeout_time - Clock::now() at the time of the call, depending on the direction of the adjustment.

The function also may block for longer than until after timeout_time has been reached due to scheduling or resource contention delays.

The behavior is undefined if valid()== false before the call to this function.


[edit] Parameters

timeout_time - maximum time point to block until

[edit] Return value

Constant Explanation
future_status::deferred The function to calculate the result has not been started yet
future_status::ready The result is ready
future_status::timeout The timeout has expired

[edit] Exceptions

Any exception thrown by clock, time_point, or duration during the execution (clocks, time points, and durations provided by the standard library never throw)

[edit] Notes

The implementations are encouraged to detect the case when valid == false before the call and throw a future_error with an error condition of future_errc::no_state.

[edit] Example

[edit] See also

waits for the result to become available
(public member function)
waits for the result, returns if it is not available for the specified timeout duration
(public member function)