[#BloombergLP-bslmt-QLockGuard]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslmt.adoc[bslmt]::QLockGuard
:relfileprefix: ../../
:mrdocs:

Guard that acquires and releases a lock on a `QLock` object&period;

== Synopsis

Declared in `&lt;bslmt&lowbar;qlock&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class QLockGuard;
----

== Description

This class provides the means to acquire and release the lock on a `QLock` object&period; Typically, the lock is acquired at construction and released automatically on destruction&period; This class also provides explicit `lock`, `tryLock`, and `unlock` primitives&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslmt/QLockGuard/2constructor-09.adoc[`QLockGuard`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bslmt/QLockGuard/2destructor.adoc[`&#126;QLockGuard`] [.small]#[destructor]#
| Destroy this object&period; If this object holds a lock, automatically free it&period;
| xref:BloombergLP/bslmt/QLockGuard/lock-0f.adoc[`lock`] 
| `lock` overloads
| xref:BloombergLP/bslmt/QLockGuard/setQLock.adoc[`setQLock`] 
| Associate this guard with the specified `qlock`&period; The behavior is undefined if this object is already in a locked state&period;
| xref:BloombergLP/bslmt/QLockGuard/tryLock.adoc[`tryLock`] 
| Attempt to acquire a lock on the associated `QLock` without blocking&period;
| xref:BloombergLP/bslmt/QLockGuard/unlock.adoc[`unlock`] 
| Release the lock on the associated `QLock`&period; The behavior is undefined unless this guard previously acquired the lock and has not already released it&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
