[#BloombergLP-bsls-BslLockGuard]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsls.adoc[bsls]::BslLockGuard
:relfileprefix: ../../
:mrdocs:

This `class` implements a guard for automatically acquiring and releasing the lock on an associated `bsls&colon;&colon;BslLock` object&period; This mechanism follows the RAII idiom whereby the lock on the `BslLock` associated with a guard object is acquired upon construction and released upon destruction&period;

== Synopsis

Declared in `&lt;bsls&lowbar;bsllock&period;h&gt;`

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

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsls/BslLockGuard/2constructor.adoc[`BslLockGuard`]         [.small]#[constructor]#
| Create a guard object that conditionally manages the specified `lock`, and acquires the lock on `lock` by invoking its `lock` method&period; The behavior is undefined unless the calling thread does not already hold the lock on `lock`&period; Note that deadlock may result if a guard is created for `lock` while the calling thread holds the lock on `lock`&period; Also note that `lock` must remain valid throughout the lifetime of this guard, or until `release` is called&period;
| xref:BloombergLP/bsls/BslLockGuard/2destructor.adoc[`&#126;BslLockGuard`] [.small]#[destructor]#
| Destroy this guard object and release the lock on the object it manages (if any) by invoking the `unlock` method of the object that was supplied at construction of this guard&period; If no lock is currently being managed, this method has no effect&period; Note that if this guard object currently manages a lock, this method assumes the behavior of `BslLock&colon;&colon;unlock`&period;
| xref:BloombergLP/bsls/BslLockGuard/release.adoc[`release`] 
| Release from management, with no effect, the object currently managed by this guard, if any&period; Note that `unlock` is _not_ called on the managed object upon its release&period;
|===



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