LLVM  6.0.0svn
Public Member Functions | List of all members
llvm::MutexGuard Class Reference

Instances of this class acquire a given Mutex Lock when constructed and hold that lock until destruction. More...

#include "llvm/Support/MutexGuard.h"

Public Member Functions

 MutexGuard (sys::Mutex &m)
 
 ~MutexGuard ()
 
bool holds (const sys::Mutex &lock) const
 holds - Returns true if this locker instance holds the specified lock. More...
 

Detailed Description

Instances of this class acquire a given Mutex Lock when constructed and hold that lock until destruction.

The intention is to instantiate one of these on the stack at the top of some scope to be assured that C++ destruction of the object will always release the Mutex and thus avoid a host of nasty multi-threading problems in the face of exceptions, etc. Guard a section of code with a Mutex.

Definition at line 27 of file MutexGuard.h.

Constructor & Destructor Documentation

◆ MutexGuard()

llvm::MutexGuard::MutexGuard ( sys::Mutex m)
inline

Definition at line 32 of file MutexGuard.h.

References llvm::sys::SmartMutex< mt_only >::lock().

◆ ~MutexGuard()

llvm::MutexGuard::~MutexGuard ( )
inline

Definition at line 33 of file MutexGuard.h.

References llvm::sys::SmartMutex< mt_only >::unlock().

Member Function Documentation

◆ holds()

bool llvm::MutexGuard::holds ( const sys::Mutex lock) const
inline

holds - Returns true if this locker instance holds the specified lock.

This is mostly used in assertions to validate that the correct mutex is held.

Definition at line 37 of file MutexGuard.h.


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