libfilezilla
Loading...
Searching...
No Matches
scoped_lock Class Referencefinal

A simple scoped lock. More...

#include <mutex.hpp>

Public Types

enum  flag { try_lock }
 

Public Member Functions

 scoped_lock (mutex &m)
 
 scoped_lock (mutex &m, flag)
 
 scoped_lock (scoped_lock const &)=delete
 
scoped_lockoperator= (scoped_lock const &)=delete
 
 scoped_lock (scoped_lock &&op) noexcept
 
scoped_lockoperator= (scoped_lock &&op) noexcept
 
void lock ()
 Obtains the mutex.
 
void unlock ()
 Releases the mutex.
 
 operator bool () const
 

Friends

class condition
 

Detailed Description

A simple scoped lock.

The lock is acquired on construction and, if still locked, released on destruction. You can manually unlock and re-lock if needed.

Note
While this can be used with recursive mutexes, scoped_lock does not implement reference counting.
Examples
events.cpp.

Member Function Documentation

◆ lock()

void lock ( )
inline

Obtains the mutex.

Locking an already locked scoped_lock results in undefined behavior.

◆ unlock()

void unlock ( )
inline

Releases the mutex.

Releasing a scoped_lock that isn't locked results in undefined behavior.


The documentation for this class was generated from the following file: