Class Semaphore

Synopsis

#include <src/uvw/thread.h>

class Semaphore final: public UnderlyingType<Semaphore, uv_sem_t>

Description

The Semaphore wrapper.

To create a Semaphore through a Loop, arguments follow:

  • An unsigned integer that specifies the initial value for the semaphore.

Inheritance

Ancestors: UnderlyingType

Methods

Semaphore
~Semaphore
postUnlocks a semaphore.
tryWaitTries to lock a semaphore.
waitLocks a semaphore.

Source

Lines 260-281 in src/uvw/thread.h.

class Semaphore final: public UnderlyingType<Semaphore, uv_sem_t> {
public:
    explicit Semaphore(ConstructorAccess ca, std::shared_ptr<Loop> ref, unsigned int value) noexcept;

    ~Semaphore() noexcept;

    /**
     * @brief Unlocks a semaphore.
     */
    void post() noexcept;

    /**
     * @brief Locks a semaphore.
     */
    void wait() noexcept;

    /**
     * @brief Tries to lock a semaphore.
     * @return True in case of success, false otherwise.
     */
    bool tryWait() noexcept;
};





Add Discussion as Guest

Log in