Documentation Home >> Headers >> <future> Header >> std::shared_future >> std::shared_future<>::wait_until Member function

Wait until the asynchronous result associated with an instance of std::shared_future is ready, or until a specified time period has elapsed.

template<typename Clock,typename Duration>
bool wait_until(
    std::chrono::time_point<Clock,Duration> const&
    absolute_time) const;

Preconditions:

this->valid() would return true.

Effects:

If the asynchronous result associated with *this contains a deferred function arising from a call to std::async that has not yet started execution, returns immediately without blocking. Otherwise blocks until the asynchronous result associated with *this is ready or Clock::now() returns a time equal to or later than absolute_time.

Returns:

std::future_status::deferred if the asynchronous result associated with *this contains a deferred function arising from a call to std::async that has not yet started execution, std::future_status::ready if the asynchronous result associated with *this is ready, std::future_status::timeout if Clock::now() returns a time equal to or later than absolute_time.

Note:

There is no guarantee as to how long the calling thread will be blocked for, only that if the function returns std::future_status::timeout then Clock::now() returned a time equal to or later than absolute_time at the point at which the thread became unblocked.

Throws:

Nothing.

Header

#include <future>

See Also