From Jason Turner

[thread.lock.unique.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpv2w3nzo7/{from.md → to.md} +72 -0
tmp/tmpv2w3nzo7/{from.md → to.md} RENAMED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##### General <a id="thread.lock.unique.general">[[thread.lock.unique.general]]</a>
2
+
3
+ ``` cpp
4
+ namespace std {
5
+ template<class Mutex>
6
+ class unique_lock {
7
+ public:
8
+ using mutex_type = Mutex;
9
+
10
+ // [thread.lock.unique.cons], construct/copy/destroy
11
+ unique_lock() noexcept;
12
+ explicit unique_lock(mutex_type& m);
13
+ unique_lock(mutex_type& m, defer_lock_t) noexcept;
14
+ unique_lock(mutex_type& m, try_to_lock_t);
15
+ unique_lock(mutex_type& m, adopt_lock_t);
16
+ template<class Clock, class Duration>
17
+ unique_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
18
+ template<class Rep, class Period>
19
+ unique_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
20
+ ~unique_lock();
21
+
22
+ unique_lock(const unique_lock&) = delete;
23
+ unique_lock& operator=(const unique_lock&) = delete;
24
+
25
+ unique_lock(unique_lock&& u) noexcept;
26
+ unique_lock& operator=(unique_lock&& u);
27
+
28
+ // [thread.lock.unique.locking], locking
29
+ void lock();
30
+ bool try_lock();
31
+
32
+ template<class Rep, class Period>
33
+ bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
34
+ template<class Clock, class Duration>
35
+ bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
36
+
37
+ void unlock();
38
+
39
+ // [thread.lock.unique.mod], modifiers
40
+ void swap(unique_lock& u) noexcept;
41
+ mutex_type* release() noexcept;
42
+
43
+ // [thread.lock.unique.obs], observers
44
+ bool owns_lock() const noexcept;
45
+ explicit operator bool () const noexcept;
46
+ mutex_type* mutex() const noexcept;
47
+
48
+ private:
49
+ mutex_type* pm; // exposition only
50
+ bool owns; // exposition only
51
+ };
52
+ }
53
+ ```
54
+
55
+ An object of type `unique_lock` controls the ownership of a lockable
56
+ object within a scope. Ownership of the lockable object may be acquired
57
+ at construction or after construction, and may be transferred, after
58
+ acquisition, to another `unique_lock` object. Objects of type
59
+ `unique_lock` are not copyable but are movable. The behavior of a
60
+ program is undefined if the contained pointer `pm` is not null and the
61
+ lockable object pointed to by `pm` does not exist for the entire
62
+ remaining lifetime [[basic.life]] of the `unique_lock` object. The
63
+ supplied `Mutex` type shall meet the *Cpp17BasicLockable* requirements
64
+ [[thread.req.lockable.basic]].
65
+
66
+ [*Note 1*: `unique_lock<Mutex>` meets the *Cpp17BasicLockable*
67
+ requirements. If `Mutex` meets the *Cpp17Lockable* requirements
68
+ [[thread.req.lockable.req]], `unique_lock<Mutex>` also meets the
69
+ *Cpp17Lockable* requirements; if `Mutex` meets the *Cpp17TimedLockable*
70
+ requirements [[thread.req.lockable.timed]], `unique_lock<Mutex>` also
71
+ meets the *Cpp17TimedLockable* requirements. — *end note*]
72
+