Open Search
    ScopedReadLock Class Reference

    #include <spinlock.h>

    Detailed Description

    The ScopedReadLock class acquires a read lock to the specified mutex upon creation and releases this upon destruction (usually at the end of a code block. This simplifies cases where your code contains many return statements where you'd otherwise have to manually unlock before returning. Only use ScopedReadLock for a short block of your code.

    THREADSAFE.

    Public Member Functions

     ScopedReadLock (RWSpinlock &lock)
     
     ScopedReadLock (ScopedReadLock &&src)
     
     ~ScopedReadLock ()
     

    Private Member Functions

     MAXON_DISALLOW_COPY_AND_ASSIGN (ScopedReadLock)
     

    Private Attributes

    RWSpinlock_lock
     

    Constructor & Destructor Documentation

    ◆ ScopedReadLock() [1/2]

    ScopedReadLock ( RWSpinlock lock)
    explicit

    Acquires read access to the specified lock (and releases it upon destruction).

    Parameters
    [in]lockThe lock to be acquired.

    ◆ ScopedReadLock() [2/2]

    Move constructor.

    ◆ ~ScopedReadLock()

    Releases the lock on destruction.

    Member Function Documentation

    ◆ MAXON_DISALLOW_COPY_AND_ASSIGN()

    MAXON_DISALLOW_COPY_AND_ASSIGN ( ScopedReadLock  )
    private

    Member Data Documentation

    ◆ _lock

    RWSpinlock* _lock
    private