[#BloombergLP-bslmt-QLockGuard] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslmt.adoc[bslmt]::QLockGuard :relfileprefix: ../../ :mrdocs: This class provides the means to acquire and release the lock on a `QLock` object. Typically, the lock is acquired at construction and released automatically on destruction. This class also provides explicit `lock`, `tryLock`, and `unlock` primitives. == Synopsis Declared in `<bslmt_qlock.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class QLockGuard; ---- == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslmt/QLockGuard/2constructor-09.adoc[`QLockGuard`] [.small]#[constructor]# | Constructors | xref:BloombergLP/bslmt/QLockGuard/2destructor.adoc[`~QLockGuard`] [.small]#[destructor]# | Destroy this object. If this object holds a lock, automatically free it. | xref:BloombergLP/bslmt/QLockGuard/lock-0f.adoc[`lock`] | `lock` overloads | xref:BloombergLP/bslmt/QLockGuard/setQLock.adoc[`setQLock`] | Associate this guard with the specified `qlock`. The behavior is undefined if this object is already in a locked state. | xref:BloombergLP/bslmt/QLockGuard/tryLock.adoc[`tryLock`] | Attempt to acquire a lock on the associated `QLock` object. Return 0 on success, a positive value of the associated QLock object is already locked, or a negative value if an error occurs. | xref:BloombergLP/bslmt/QLockGuard/unlock.adoc[`unlock`] | Release the lock on the associated `QLock`. The behavior is undefined unless this guard previously acquired the lock and has not already released it. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#