Files
cppdraft_translate/cppdraft/thread/lock/unique/cons.md
2025-10-25 03:02:53 +03:00

6.0 KiB
Raw Blame History

[thread.lock.unique.cons]

32 Concurrency support library [thread]

32.6 Mutual exclusion [thread.mutex]

32.6.5 Locks [thread.lock]

32.6.5.4 Class template unique_lock [thread.lock.unique]

32.6.5.4.2 Constructors, destructor, and assignment [thread.lock.unique.cons]

🔗

unique_lock() noexcept;

1

#

Postconditions: pm == nullptr and owns == false.

🔗

explicit unique_lock(mutex_type& m);

2

#

Effects: Calls m.lock().

3

#

Postconditions: pm == addressof(m) and owns == true.

🔗

unique_lock(mutex_type& m, defer_lock_t) noexcept;

4

#

Postconditions: pm == addressof(m) and owns == false.

🔗

unique_lock(mutex_type& m, try_to_lock_t);

5

#

Preconditions: The supplied Mutex type meets the Cpp17Lockable requirements ([thread.req.lockable.req]).

6

#

Effects: Calls m.try_lock().

7

#

Postconditions: pm == addressof(m) and owns == res, where res is the value returned by the call to m.try_lock().

🔗

unique_lock(mutex_type& m, adopt_lock_t);

8

#

Preconditions: The calling thread holds a non-shared lock on m.

9

#

Postconditions: pm == addressof(m) and owns == true.

10

#

Throws: Nothing.

🔗

template<class Clock, class Duration> unique_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);

11

#

Preconditions: The supplied Mutex type meets theCpp17TimedLockable requirements ([thread.req.lockable.timed]).

12

#

Effects: Calls m.try_lock_until(abs_time).

13

#

Postconditions: pm == addressof(m) and owns == res, where res is the value returned by the call to m.try_lock_until(abs_time).

🔗

template<class Rep, class Period> unique_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);

14

#

Preconditions: The supplied Mutex type meets the Cpp17TimedLockable requirements ([thread.req.lockable.timed]).

15

#

Effects: Calls m.try_lock_for(rel_time).

16

#

Postconditions: pm == addressof(m) and owns == res, where res is the value returned by the call to m.try_lock_for(rel_time).

🔗

unique_lock(unique_lock&& u) noexcept;

17

#

Postconditions: pm == u_p.pm and owns == u_p.owns (where u_p is the state of u just prior to this construction), u.pm == 0 and u.owns == false.

🔗

unique_lock& operator=(unique_lock&& u) noexcept;

18

#

Effects: Equivalent to: unique_lock(std::move(u)).swap(*this)

19

#

Returns: *this.

🔗

~unique_lock();

20

#

Effects: If owns calls pm->unlock().