[#BloombergLP-bslmt-TestUtil_Guard]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslmt.adoc[bslmt]::TestUtil&lowbar;Guard
:relfileprefix: ../../
:mrdocs:

This `class` defines an object that provides exclusive access to the critical sections defined by this component&apos;s macros&period; Multiple `Guard` objects can exist at once, but only in the same thread &hyphen;&hyphen; if an attempt is made to construct a `Guard` while any `Guard`s exist in other threads, the constructor will block until all `Guard` objects in other threads are destroyed&period; The behavior is undefined if a `Guard` object is anywhere but on the stack&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class TestUtil&lowbar;Guard;
----

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslmt/TestUtil_Guard/BoolType.adoc[`BoolType`] 
| Type used to provide a testable `bool` conversion for this object&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslmt/TestUtil_Guard/2constructor.adoc[`TestUtil&lowbar;Guard`]         [.small]#[constructor]#
| Create a guard that locks the mutex in the singleton and saves the address of the singleton mutex&period;
| xref:BloombergLP/bslmt/TestUtil_Guard/2destructor.adoc[`&#126;TestUtil&lowbar;Guard`] [.small]#[destructor]#
| Unlock the recursive mutex that was locked by the constructor&period;
| xref:BloombergLP/bslmt/TestUtil_Guard/operator_assign.adoc[`operator&equals;`] 
| Set the boolean state of this object to the specified `rhs`&period;
| xref:BloombergLP/bslmt/TestUtil_Guard/2conversion.adoc[`operator TestUtil&lowbar;Guard::BoolType`] 
| Return the boolean state of this `TestUtil&lowbar;Guard` object&period;
|===



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