just::thread Complete C++ Standard Thread Library by Just Software Solutions

Documentation Home >> Headers >> <condition_variable> Header >> std::condition_variable_any class

The std::condition_variable_any class allows a thread to wait for a condition to become true. Whereas std::condition_variable can only be used with std::unique_lock<std::mutex>, std::condition_variable_any can be used with any type that meets the Lockable Requirements.

Instances of std::condition_variable_any are not CopyAssignable, CopyConstructible, MoveAssignable or MoveConstructible.

class condition_variable_any
{
public:
    condition_variable_any();
    ~condition_variable_any();

    condition_variable_any(
        condition_variable_any const& ) = delete;
    condition_variable_any& operator=(
        condition_variable_any const& ) = delete;

    void notify_one();
    void notify_all();

    template<typename Lockable>
    void wait(Lockable& lock);

    template <typename Lockable, typename Predicate>
    void wait(Lockable& lock, Predicate pred);

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

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

    template <
        typename Lockable, typename Rep,
        typename Period>
    std::cv_status wait_for(
        Lockable& lock,
        const std::chrono::duration<Rep, Period>&
        relative_time);

    template <
        typename Lockable, typename Rep,
        typename Period, typename Predicate>
    bool wait_for(
        Lockable& lock,
        const std::chrono::duration<Rep, Period>&
        relative_time,
        Predicate pred);
};
Header

#include <condition_variable>

See Also