Class Mutex

Synopsis

#include <src/uvw/thread.h>

class Mutex final: public UnderlyingType<Mutex, uv_mutex_t>

Description

The Mutex wrapper.

To create a Mutex through a Loop, arguments follow:

  • An option boolean that specifies if the mutex is a recursive one. The default value is false, the mutex isn't recursive.

Inheritance

Ancestors: UnderlyingType

Methods

Mutex
~Mutex
lockLocks the mutex.
tryLockTries to lock the mutex.
unlockUnlocks the mutex.

Source

Lines 184-207 in src/uvw/thread.h.

class Mutex final: public UnderlyingType<Mutex, uv_mutex_t> {
    friend class Condition;

public:
    explicit Mutex(ConstructorAccess ca, std::shared_ptr<Loop> ref, bool recursive = false) noexcept;

    ~Mutex() noexcept;

    /**
     * @brief Locks the mutex.
     */
    void lock() noexcept;

    /**
     * @brief Tries to lock the mutex.
     * @return True in case of success, false otherwise.
     */
    bool tryLock() noexcept;

    /**
     * @brief Unlocks the mutex.
     */
    void unlock() noexcept;
};





Add Discussion as Guest

Log in