File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -151,3 +151,32 @@ void virt_inherited_mutexes_different_bases_tn(CombinedVirtMutex &cvt) {
151
151
cvt.unlock2 (); // Despite a different name, unlock2 acts on the same mutex as lock1
152
152
sleep (10 );
153
153
}
154
+ namespace std {
155
+ template <class ... MutexTypes> struct scoped_lock {
156
+ explicit scoped_lock (MutexTypes&... m);
157
+ ~scoped_lock ();
158
+ };
159
+ template <class MutexType > class scoped_lock <MutexType> {
160
+ public:
161
+ explicit scoped_lock (MutexType& m) : m(m) { m.lock (); }
162
+ ~scoped_lock () { m.unlock (); }
163
+ private:
164
+ MutexType& m;
165
+ };
166
+ } // namespace std
167
+
168
+ namespace gh_104241 {
169
+ int magic_number;
170
+ std::mutex m;
171
+
172
+ void fixed () {
173
+ int current;
174
+ for (int items_processed = 0 ; items_processed < 100 ; ++items_processed) {
175
+ {
176
+ std::scoped_lock<std::mutex> guard (m);
177
+ current = magic_number;
178
+ }
179
+ sleep (current); // expected no warning
180
+ }
181
+ }
182
+ } // namespace gh_104241
You can’t perform that action at this time.
0 commit comments