Class Condition

Synopsis

#include <src/uvw/thread.h>

class Condition final: public UnderlyingType<Condition, uv_cond_t>

Description

The Condition wrapper.

Inheritance

Ancestors: UnderlyingType

Methods

Condition
~Condition
broadcastBroadcasts a condition.
signalSignals a condition.
timedWaitWaits on a condition.
waitWaits on a condition.

Source

Lines 287-335 in src/uvw/thread.h.

class Condition final: public UnderlyingType<Condition, uv_cond_t> {
public:
    explicit Condition(ConstructorAccess ca, std::shared_ptr<Loop> ref) noexcept;

    ~Condition() noexcept;

    /**
     * @brief Signals a condition.
     *
     * This function shall unblock at least one of the threads that are blocked
     * on the specified condition variable (if any threads are blocked on it).
     */
    void signal() noexcept;

    /**
     * @brief Broadcasts a condition.
     *
     * This function shall unblock threads blocked on a condition variable.
     */
    void broadcast() noexcept;

    /**
     * @brief Waits on a condition.
     *
     * These function atomically releases the mutex and causes the calling
     * thread to block on the condition variable.
     *
     * @param mutex A mutex locked by the calling thread, otherwise expect
     * undefined behavior.
     */
    void wait(Mutex &mutex) noexcept;

    /**
     * @brief Waits on a condition.
     *
     * These function atomically releases the mutex and causes the calling
     * thread to block on the condition variable.<br/>
     * The functions returns with an error if the absolute time specified passes
     * (that is, system time equals or exceeds it) before the condition is
     * signaled or broadcasted, or if the absolute time specified has already
     * been passed at the time of the call.
     *
     * @param mutex A mutex locked by the calling thread, otherwise expect
     * undefined behavior.
     * @param timeout The maximum time to wait before to return.
     * @return True in case of success, false otherwise.
     */
    bool timedWait(Mutex &mutex, uint64_t timeout) noexcept;
};





Add Discussion as Guest

Log in