Title: [277992] trunk/Tools
Revision
277992
Author
cdu...@apple.com
Date
2021-05-24 20:16:51 -0700 (Mon, 24 May 2021)

Log Message

Stop using UncheckedLock in Condition API tests
https://bugs.webkit.org/show_bug.cgi?id=226198

Reviewed by Sam Weinig.

Stop using UncheckedLock in Condition API tests. This is a step towards phasing out UncheckedLock
in favor the Lock so that we can benefit from Clang Thread Safety Analysis.

* TestWebKitAPI/Tests/WTF/Condition.cpp:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (277991 => 277992)


--- trunk/Tools/ChangeLog	2021-05-25 03:13:40 UTC (rev 277991)
+++ trunk/Tools/ChangeLog	2021-05-25 03:16:51 UTC (rev 277992)
@@ -1,3 +1,15 @@
+2021-05-24  Chris Dumez  <cdu...@apple.com>
+
+        Stop using UncheckedLock in Condition API tests
+        https://bugs.webkit.org/show_bug.cgi?id=226198
+
+        Reviewed by Sam Weinig.
+
+        Stop using UncheckedLock in Condition API tests. This is a step towards phasing out UncheckedLock
+        in favor the Lock so that we can benefit from Clang Thread Safety Analysis.
+
+        * TestWebKitAPI/Tests/WTF/Condition.cpp:
+
 2021-05-24  Mark Lam  <mark....@apple.com>
 
         Raise jitMemoryReservationSize for ftl-no-cjit-small-pool* tests.

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/Condition.cpp (277991 => 277992)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/Condition.cpp	2021-05-25 03:13:40 UTC (rev 277991)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/Condition.cpp	2021-05-25 03:16:51 UTC (rev 277992)
@@ -38,6 +38,7 @@
 
 namespace {
 
+static Lock lock;
 static constexpr bool verbose = false;
 
 enum NotifyStyle {
@@ -46,20 +47,20 @@
 };
 
 template<typename Functor>
-void wait(UncheckedCondition& condition, std::unique_lock<UncheckedLock>& locker, const Functor& predicate, Seconds timeout)
+void wait(Condition& condition, const Functor& predicate, Seconds timeout) WTF_REQUIRES_LOCK(lock)
 {
     if (timeout == Seconds::infinity())
-        condition.wait(locker, predicate);
+        condition.wait(lock, predicate);
     else {
         // This tests timeouts in the sense that it verifies that we can call wait() again after a
         // timeout happened. That's a non-trivial piece of functionality since upon timeout the
         // ParkingLot has to remove us from the queue.
         while (!predicate())
-            condition.waitFor(locker, timeout, predicate);
+            condition.waitFor(lock, timeout, predicate);
     }
 }
 
-void notify(NotifyStyle notifyStyle, UncheckedCondition& condition, bool shouldNotify)
+void notify(NotifyStyle notifyStyle, Condition& condition, bool shouldNotify)
 {
     switch (notifyStyle) {
     case AlwaysNotifyOne:
@@ -83,9 +84,8 @@
 {
     Deque<unsigned> queue;
     bool shouldContinue = true;
-    UncheckedLock lock;
-    UncheckedCondition emptyCondition;
-    UncheckedCondition fullCondition;
+    Condition emptyCondition;
+    Condition fullCondition;
 
     Vector<Ref<Thread>> consumerThreads;
     Vector<Ref<Thread>> producerThreads;
@@ -101,9 +101,9 @@
                     unsigned result;
                     unsigned shouldNotify = false;
                     {
-                        std::unique_lock<UncheckedLock> locker(lock);
+                        Locker locker { lock };
                         wait(
-                            emptyCondition, locker, 
+                            emptyCondition,
                             [&] () {
                                 if (verbose)
                                     dataLog(toString(Thread::current(), ": Checking consumption predicate with shouldContinue = ", shouldContinue, ", queue.size() == ", queue.size(), "\n"));
@@ -134,9 +134,9 @@
                 for (unsigned i = 0; i < numMessagesPerProducer; ++i) {
                     bool shouldNotify = false;
                     {
-                        std::unique_lock<UncheckedLock> locker(lock);
+                        Locker locker { lock };
                         wait(
-                            fullCondition, locker,
+                            fullCondition,
                             [&] () {
                                 if (verbose)
                                     dataLog(toString(Thread::current(), ": Checking production predicate with shouldContinue = ", shouldContinue, ", queue.size() == ", queue.size(), "\n"));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to