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

Schedule a handler invocation after `duration` unless released&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
guard(
    xref:BloombergLP/bsls/TimeInterval.adoc[bsls::TimeInterval] const& duration,
    std::string&lowbar;view const& text);
----

== Description

Configure a thread to, at the expiration of the specified `duration`, invoke the handler assigned at object creation with the specified `text`, unless the `release` method is invoked or this guard is rescheduled with a subsequent call to `guard`&period; Return 0 on success, and a non&hyphen;zero value if a thread is not available and could not be created&period; The behavior is undefined unless `duration` is a positive value&period;

== Return Value

0 on success, and a non&hyphen;zero value otherwise

== Parameters

[cols="1,4"]
|===
| Name| Description
| *duration*
| positive interval until the handler may be invoked
| *text*
| diagnostic text passed to the handler on expiration
|===


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