Skip to content

Commit 15cf6aa

Browse files
committed
Review comments
1 parent 0807902 commit 15cf6aa

File tree

8 files changed

+30
-46
lines changed

8 files changed

+30
-46
lines changed

libcxx/test/std/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,11 @@ int main(int, char**) {
6565
}
6666

6767
// Acquire the same mutex as t1. This ensures that the condition variable has started
68-
// waiting (and hence released that mutex). We don't actually need to hold the lock, we
69-
// simply use it as a signal that the condition variable has started waiting.
68+
// waiting (and hence released that mutex).
7069
std::unique_lock<std::mutex> lock(mutex);
71-
lock.unlock();
7270

7371
likely_spurious = false;
72+
lock.unlock();
7473
cv.notify_one();
7574
});
7675

@@ -134,8 +133,7 @@ int main(int, char**) {
134133
}
135134

136135
// Acquire the same mutex as t1. This ensures that the condition variable has started
137-
// waiting (and hence released that mutex). We don't actually need to hold the lock, we
138-
// simply use it as a signal that the condition variable has started waiting.
136+
// waiting (and hence released that mutex).
139137
std::unique_lock<std::mutex> lock(mutex);
140138
lock.unlock();
141139

@@ -145,7 +143,8 @@ int main(int, char**) {
145143
// We would want to assert that the thread has been awoken after this time,
146144
// however nothing guarantees us that it ever gets spuriously awoken, so
147145
// we can't really check anything. This is still left here as documentation.
148-
assert(awoken || !awoken);
146+
bool woke = awoken.load();
147+
assert(woke || !woke);
149148

150149
// Whatever happened, actually awaken the condition variable to ensure the test
151150
// doesn't keep running until the timeout.

libcxx/test/std/thread/thread.condition/thread.condition.condvar/wait_pred.pass.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ int main(int, char**) {
4848
}
4949

5050
// Acquire the same mutex as t1. This ensures that the condition variable has started
51-
// waiting (and hence released that mutex). We don't actually need to hold the lock, we
52-
// simply use it as a signal that the condition variable has started waiting.
51+
// waiting (and hence released that mutex).
5352
std::unique_lock<std::mutex> lock(mutex);
54-
lock.unlock();
5553

5654
likely_spurious = false;
55+
lock.unlock();
5756
cv.notify_one();
5857
});
5958

@@ -89,8 +88,7 @@ int main(int, char**) {
8988
}
9089

9190
// Acquire the same mutex as t1. This ensures that the condition variable has started
92-
// waiting (and hence released that mutex). We don't actually need to hold the lock, we
93-
// simply use it as a signal that the condition variable has started waiting.
91+
// waiting (and hence released that mutex).
9492
std::unique_lock<std::mutex> lock(mutex);
9593
lock.unlock();
9694

@@ -100,7 +98,8 @@ int main(int, char**) {
10098
// We would want to assert that the thread has been awoken after this time,
10199
// however nothing guarantees us that it ever gets spuriously awoken, so
102100
// we can't really check anything. This is still left here as documentation.
103-
assert(awoken || !awoken);
101+
bool woke = awoken.load();
102+
assert(woke || !woke);
104103

105104
// Whatever happened, actually awaken the condition variable to ensure the test finishes.
106105
cv.notify_one();

libcxx/test/std/thread/thread.condition/thread.condition.condvar/wait_until.pass.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,5 @@ void test() {
113113
int main(int, char**) {
114114
test<TestClock>();
115115
test<std::chrono::steady_clock>();
116-
test<std::chrono::system_clock>();
117116
return 0;
118117
}

libcxx/test/std/thread/thread.condition/thread.condition.condvar/wait_until_pred.pass.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,11 @@ void test() {
6969
}
7070

7171
// Acquire the same mutex as t1. This ensures that the condition variable has started
72-
// waiting (and hence released that mutex). We don't actually need to hold the lock, we
73-
// simply use it as a signal that the condition variable has started waiting.
72+
// waiting (and hence released that mutex).
7473
std::unique_lock<std::mutex> lock(mutex);
75-
lock.unlock();
7674

7775
likely_spurious = false;
76+
lock.unlock();
7877
cv.notify_one();
7978
});
8079

@@ -134,8 +133,7 @@ void test() {
134133
}
135134

136135
// Acquire the same mutex as t1. This ensures that the condition variable has started
137-
// waiting (and hence released that mutex). We don't actually need to hold the lock, we
138-
// simply use it as a signal that the condition variable has started waiting.
136+
// waiting (and hence released that mutex).
139137
std::unique_lock<std::mutex> lock(mutex);
140138
lock.unlock();
141139

@@ -145,7 +143,8 @@ void test() {
145143
// We would want to assert that the thread has been awoken after this time,
146144
// however nothing guarantees us that it ever gets spuriously awoken, so
147145
// we can't really check anything. This is still left here as documentation.
148-
assert(awoken || !awoken);
146+
bool woke = awoken.load();
147+
assert(woke || !woke);
149148

150149
// Whatever happened, actually awaken the condition variable to ensure the test
151150
// doesn't keep running until the timeout.
@@ -160,6 +159,5 @@ void test() {
160159
int main(int, char**) {
161160
test<TestClock>();
162161
test<std::chrono::steady_clock>();
163-
test<std::chrono::system_clock>();
164162
return 0;
165163
}

libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_for_pred.pass.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,11 @@ void test() {
7171
}
7272

7373
// Acquire the same mutex as t1. This ensures that the condition variable has started
74-
// waiting (and hence released that mutex). We don't actually need to hold the lock, we
75-
// simply use it as a signal that the condition variable has started waiting.
74+
// waiting (and hence released that mutex).
7675
Lock lock(mutex);
77-
lock.unlock();
7876

7977
likely_spurious = false;
78+
lock.unlock();
8079
cv.notify_one();
8180
});
8281

@@ -140,8 +139,7 @@ void test() {
140139
}
141140

142141
// Acquire the same mutex as t1. This ensures that the condition variable has started
143-
// waiting (and hence released that mutex). We don't actually need to hold the lock, we
144-
// simply use it as a signal that the condition variable has started waiting.
142+
// waiting (and hence released that mutex).
145143
Lock lock(mutex);
146144
lock.unlock();
147145

@@ -151,7 +149,8 @@ void test() {
151149
// We would want to assert that the thread has been awoken after this time,
152150
// however nothing guarantees us that it ever gets spuriously awoken, so
153151
// we can't really check anything. This is still left here as documentation.
154-
assert(awoken || !awoken);
152+
bool woke = awoken.load();
153+
assert(woke || !woke);
155154

156155
// Whatever happened, actually awaken the condition variable to ensure the test
157156
// doesn't keep running until the timeout.

libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_pred.pass.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,11 @@ void test() {
5656
}
5757

5858
// Acquire the same mutex as t1. This ensures that the condition variable has started
59-
// waiting (and hence released that mutex). We don't actually need to hold the lock, we
60-
// simply use it as a signal that the condition variable has started waiting.
59+
// waiting (and hence released that mutex).
6160
Lock lock(mutex);
62-
lock.unlock();
6361

6462
likely_spurious = false;
63+
lock.unlock();
6564
cv.notify_one();
6665
});
6766

@@ -97,8 +96,7 @@ void test() {
9796
}
9897

9998
// Acquire the same mutex as t1. This ensures that the condition variable has started
100-
// waiting (and hence released that mutex). We don't actually need to hold the lock, we
101-
// simply use it as a signal that the condition variable has started waiting.
99+
// waiting (and hence released that mutex).
102100
Lock lock(mutex);
103101
lock.unlock();
104102

@@ -108,7 +106,8 @@ void test() {
108106
// We would want to assert that the thread has been awoken after this time,
109107
// however nothing guarantees us that it ever gets spuriously awoken, so
110108
// we can't really check anything. This is still left here as documentation.
111-
assert(awoken || !awoken);
109+
bool woke = awoken.load();
110+
assert(woke || !woke);
112111

113112
// Whatever happened, actually awaken the condition variable to ensure the test finishes.
114113
cv.notify_one();

libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_until.pass.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,14 @@ void test() {
118118
int main(int, char**) {
119119
test<std::unique_lock<std::mutex>, TestClock>();
120120
test<std::unique_lock<std::mutex>, std::chrono::steady_clock>();
121-
test<std::unique_lock<std::mutex>, std::chrono::system_clock>();
122121

123122
test<std::unique_lock<std::timed_mutex>, TestClock>();
124123
test<std::unique_lock<std::timed_mutex>, std::chrono::steady_clock>();
125-
test<std::unique_lock<std::timed_mutex>, std::chrono::system_clock>();
126124

127125
test<MyLock<std::mutex>, TestClock>();
128126
test<MyLock<std::mutex>, std::chrono::steady_clock>();
129-
test<MyLock<std::mutex>, std::chrono::system_clock>();
130127

131128
test<MyLock<std::timed_mutex>, TestClock>();
132129
test<MyLock<std::timed_mutex>, std::chrono::steady_clock>();
133-
test<MyLock<std::timed_mutex>, std::chrono::system_clock>();
134130
return 0;
135131
}

libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_until_pred.pass.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,11 @@ void test() {
7575
}
7676

7777
// Acquire the same mutex as t1. This ensures that the condition variable has started
78-
// waiting (and hence released that mutex). We don't actually need to hold the lock, we
79-
// simply use it as a signal that the condition variable has started waiting.
78+
// waiting (and hence released that mutex).
8079
Lock lock(mutex);
81-
lock.unlock();
8280

8381
likely_spurious = false;
82+
lock.unlock();
8483
cv.notify_one();
8584
});
8685

@@ -140,8 +139,7 @@ void test() {
140139
}
141140

142141
// Acquire the same mutex as t1. This ensures that the condition variable has started
143-
// waiting (and hence released that mutex). We don't actually need to hold the lock, we
144-
// simply use it as a signal that the condition variable has started waiting.
142+
// waiting (and hence released that mutex).
145143
Lock lock(mutex);
146144
lock.unlock();
147145

@@ -151,7 +149,8 @@ void test() {
151149
// We would want to assert that the thread has been awoken after this time,
152150
// however nothing guarantees us that it ever gets spuriously awoken, so
153151
// we can't really check anything. This is still left here as documentation.
154-
assert(awoken || !awoken);
152+
bool woke = awoken.load();
153+
assert(woke || !woke);
155154

156155
// Whatever happened, actually awaken the condition variable to ensure the test
157156
// doesn't keep running until the timeout.
@@ -169,22 +168,18 @@ int main(int, char**) {
169168
support::make_test_thread([] {
170169
test<std::unique_lock<std::mutex>, TestClock>();
171170
test<std::unique_lock<std::mutex>, std::chrono::steady_clock>();
172-
test<std::unique_lock<std::mutex>, std::chrono::system_clock>();
173171
}),
174172
support::make_test_thread([] {
175173
test<std::unique_lock<std::timed_mutex>, TestClock>();
176174
test<std::unique_lock<std::timed_mutex>, std::chrono::steady_clock>();
177-
test<std::unique_lock<std::timed_mutex>, std::chrono::system_clock>();
178175
}),
179176
support::make_test_thread([] {
180177
test<MyLock<std::mutex>, TestClock>();
181178
test<MyLock<std::mutex>, std::chrono::steady_clock>();
182-
test<MyLock<std::mutex>, std::chrono::system_clock>();
183179
}),
184180
support::make_test_thread([] {
185181
test<MyLock<std::timed_mutex>, TestClock>();
186182
test<MyLock<std::timed_mutex>, std::chrono::steady_clock>();
187-
test<MyLock<std::timed_mutex>, std::chrono::system_clock>();
188183
})};
189184

190185
for (std::thread& t : tests)

0 commit comments

Comments
 (0)