From Jason Turner

[thread.lock.shared.general]

Diff to HTML by rtfpessoa

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