Share via


condition_variable::wait_until Method

Blocks a thread, and sets a maximum point in time at which the thread unblocks.

template<
   class Clock,
   class Duration
>
cv_status wait_until(
   unique_lock<mutex>& Lck,
   const chrono::time_point<Clock,
   Duration>& Abs_time
);
template<
   class Clock,
   class Duration,
   class Predicate
>
bool wait_until(
   unique_lock<mutex>& Lck,
   const chrono::time_point<Clock,
   Duration>& Abs_time,
   Predicate Pred
);
cv_status wait_until(
   unique_lock<mutex>& Lck,
   const xtime *Abs_time
);
template<class Predicate>
bool wait_until(
   unique_lock<mutex>& Lck,
   const xtime *Abs_time,
   Predicate Pred
);

Parameters

  • Lck
    A unique_lock<mutex> object.

  • Abs_time
    A chrono::time_point object.

  • Pred
    Any expression that returns true or false.

Return Value

Methods that return a cv_status type return cv_status::timeout if the wait terminates when Abs_time elapses. Otherwise, the methods return cv_status::no_timeout.

Methods that return a bool return the value of Pred.

Remarks

The first method blocks until the condition_variable object is signaled by a call to notify_one or notify_all or until Abs_time. It can also wake up spuriously.

In effect, the second method executes the following code

while(!Pred())
   if(wait_until(Lck, Abs_time) == cv_status::timeout)
      return Pred();
return true;

The third and fourth methods use a pointer to an object of type xtime to replace the chrono::time_point object. The xtime object specifies the maximum amount of time to wait for a signal.

Requirements

Header: condition_variable

Namespace: std

See Also

Reference

condition_variable Class

<condition_variable>