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

Attempt to acquire the lock&semi; optionally specify the `numRetries` times to attempt again if this object is already locked&period; Return 0 on success, and a non&hyphen;zero value if the lock was not successfully acquired&period; The behavior is undefined unless `0 &lt;&equals; numRetries`&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
tryLock(int numRetries = 0);
----


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