[#BloombergLP-bslmt-LockGuardUnlock-2constructor-09] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslmt.adoc[bslmt]::xref:BloombergLP/bslmt/LockGuardUnlock.adoc[LockGuardUnlock]::LockGuardUnlock :relfileprefix: ../../../ :mrdocs: Create a guard that optionally unlocks `lock`. == Synopsis Declared in `<bslmt_lockguard.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- LockGuardUnlock( T* lock, bool alreadyUnlockedFlag); ---- == Description Create a scoped guard that conditionally manages the specified `lock` (if non‐null) and invokes `lock‐>unlock()` if the specified `alreadyUnlockedFlag` is `false`. Supplying a null `lock` has no effect. The behavior is undefined unless the state of `lock` (if non‐null) is consistent with `alreadyUnlockedFlag`. Note that `alreadyUnlockedFlag` is used to indicate whether `lock` is in an already‐unlocked state when passed, so if `alreadyUnlockedFlag` is `true` the `unlock` method will _not_ be called on the supplied `lock`. Also note that `lock` must remain valid throughout the lifetime of this guard, or until `release` is called. == Parameters [cols="1,4"] |=== | Name| Description | *lock* | lock object to unlock; may be null | *alreadyUnlockedFlag* | `true` if `lock` is already unlocked |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#