[#std-shared_lock-0b-2constructor-0c]
= xref:std.adoc[std]::xref:std/shared_lock-0b.adoc[shared&lowbar;lock&lt;folly::SharedMutexImpl&lt;ReaderPriority, Tag&lowbar;, Atom, Policy&gt;&gt;]::shared&lowbar;lock
:relfileprefix: ../../
:mrdocs:

Constructors

== Synopses

Declared in `&lt;folly&sol;SharedMutex&period;h&gt;`

Constructs a lock that owns no mutex&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:std/shared_lock-0b/2constructor-04.adoc[shared&lowbar;lock]() noexcept = default;
----

[.small]#xref:std/shared_lock-0b/2constructor-04.adoc[_» more&period;&period;&period;_]#

Deleted copy constructor&semi; the lock is not copyable&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:std/shared_lock-0b/2constructor-07d.adoc[shared&lowbar;lock](xref:std/shared_lock-0b.adoc[shared&lowbar;lock] const& other) = delete;
----

[.small]#xref:std/shared_lock-0b/2constructor-07d.adoc[_» more&period;&period;&period;_]#

Move&hyphen;constructs a lock, transferring ownership from another lock&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:std/shared_lock-0b/2constructor-00b.adoc[shared&lowbar;lock](xref:std/shared_lock-0b.adoc[shared&lowbar;lock]&& other) noexcept;
----

[.small]#xref:std/shared_lock-0b/2constructor-00b.adoc[_» more&period;&period;&period;_]#

Constructs a lock and acquires the mutex in shared mode&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
explicit
xref:std/shared_lock-0b/2constructor-0d.adoc[shared&lowbar;lock](xref:std/shared_lock-0b/mutex_type.adoc[mutex&lowbar;type]& mutex);
----

[.small]#xref:std/shared_lock-0b/2constructor-0d.adoc[_» more&period;&period;&period;_]#

Constructs a lock that adopts an already&hyphen;held shared lock&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
xref:std/shared_lock-0b/2constructor-05.adoc[shared&lowbar;lock](
    xref:std/shared_lock-0b/mutex_type.adoc[mutex&lowbar;type]& mutex,
    std::adopt&lowbar;lock&lowbar;t unused);
----

[.small]#xref:std/shared_lock-0b/2constructor-05.adoc[_» more&period;&period;&period;_]#

Constructs a lock that manages a mutex without acquiring it&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:std/shared_lock-0b/2constructor-0a.adoc[shared&lowbar;lock](
    xref:std/shared_lock-0b/mutex_type.adoc[mutex&lowbar;type]& mutex,
    std::defer&lowbar;lock&lowbar;t unused) noexcept;
----

[.small]#xref:std/shared_lock-0b/2constructor-0a.adoc[_» more&period;&period;&period;_]#

Constructs a lock and tries to acquire the mutex without blocking&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
xref:std/shared_lock-0b/2constructor-08.adoc[shared&lowbar;lock](
    xref:std/shared_lock-0b/mutex_type.adoc[mutex&lowbar;type]& mutex,
    std::try&lowbar;to&lowbar;lock&lowbar;t unused);
----

[.small]#xref:std/shared_lock-0b/2constructor-08.adoc[_» more&period;&period;&period;_]#

Constructs a lock and tries to acquire the mutex within a duration&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename Rep,
    typename Period&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
xref:std/shared_lock-0b/2constructor-00e.adoc[shared&lowbar;lock](
    xref:std/shared_lock-0b/mutex_type.adoc[mutex&lowbar;type]& mutex,
    std::chrono::duration&lt;Rep, Period&gt; const& timeout);
----

[.small]#xref:std/shared_lock-0b/2constructor-00e.adoc[_» more&period;&period;&period;_]#

Constructs a lock and tries to acquire the mutex by a deadline&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename Clock,
    typename Duration&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
xref:std/shared_lock-0b/2constructor-078.adoc[shared&lowbar;lock](
    xref:std/shared_lock-0b/mutex_type.adoc[mutex&lowbar;type]& mutex,
    std::chrono::time&lowbar;point&lt;Clock, Duration&gt; const& deadline);
----

[.small]#xref:std/shared_lock-0b/2constructor-078.adoc[_» more&period;&period;&period;_]#

== Parameters

[cols="1,4"]
|===
| Name| Description
| *other*
| The lock that would be copied from&period;
| *mutex*
| Mutex to lock&period;
| *unused*
| Tag selecting lock adoption&period;
| *timeout*
| Maximum time to wait for the lock&period;
| *deadline*
| Absolute time by which the lock must be acquired&period;
|===


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