[PATCH] D65708: [NFC][DirectoryWatchedTests] Unlocking mutexes before signaling condition variable.
Puyan Lotfi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 3 18:37:48 PDT 2019
plotfi created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
plotfi added reviewers: compnerd, jkorous.
Herald added a subscriber: dexonsmith.
This should not affect actual behavior, but should pessimize the threading less by avoiding the situation where:
- mutex is still locked
- T1 notifies on condition variable
- T2 wakes to check mutex
- T2 sees mutex is still locked
- T2 waits
- T1 unlocks mutex
- T2 tries again, acquires mutex.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D65708
Files:
clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===================================================================
--- clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -132,8 +132,10 @@
} else {
ExpectedInitial.erase(It);
}
- if (result())
+ if (result()) {
+ L.unlock();
ResultIsReady.notify_one();
+ }
}
void consumeNonInitial(DirectoryWatcher::Event E) {
@@ -151,8 +153,10 @@
} else {
ExpectedNonInitial.erase(It);
}
- if (result())
+ if (result()) {
+ L.unlock();
ResultIsReady.notify_one();
+ }
}
// This method is used by DirectoryWatcher.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65708.213220.patch
Type: text/x-patch
Size: 730 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190804/ed8b4c0e/attachment.bin>
More information about the cfe-commits
mailing list