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

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

The std::condition_variable class allows a thread to wait for a condition to become true.

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

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

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

    void notify_one();
    void notify_all();

    void wait(std::unique_lock<std::mutex>& lock);

    template <typename Predicate>
    void wait(std::unique_lock<std::mutex>& lock,
        Predicate pred);

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

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

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

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

void notify_all_at_thread_exit(
    condition_variable&,unique_lock<mutex>);
Header

#include <condition_variable>

See Also