libfilezilla
Public Member Functions | Friends | List of all members
scoped_lock Class Referencefinal

A simple scoped lock. More...

#include <mutex.hpp>

Public Member Functions

 scoped_lock (mutex &m)
 
 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. More...
 
void unlock ()
 Releases the mutex. More...
 

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: