diff options
author | Puyan Lotfi <puyan@puyan.org> | 2019-08-06 01:26:46 +0000 |
---|---|---|
committer | Puyan Lotfi <puyan@puyan.org> | 2019-08-06 01:26:46 +0000 |
commit | fa086d701a22067ca6602c7f1f57c35d17600af1 (patch) | |
tree | 5f335eca6fb815121821100325cfda0726d5fda2 /clang/unittests/DirectoryWatcher | |
parent | de4060816fa06c8acaef4fbfe1f687b69a430dac (diff) | |
download | bcm5719-llvm-fa086d701a22067ca6602c7f1f57c35d17600af1.tar.gz bcm5719-llvm-fa086d701a22067ca6602c7f1f57c35d17600af1.zip |
[NFC][DirectoryWatchedTests] Unlocks mutexes before signaling condition variable
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.
Differential Revision: https://reviews.llvm.org/D65708
llvm-svn: 367968
Diffstat (limited to 'clang/unittests/DirectoryWatcher')
-rw-r--r-- | clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp b/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp index c26ba57354f..52a69616057 100644 --- a/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp +++ b/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp @@ -132,8 +132,10 @@ struct VerifyingConsumer { } else { ExpectedInitial.erase(It); } - if (result()) + if (result()) { + L.unlock(); ResultIsReady.notify_one(); + } } void consumeNonInitial(DirectoryWatcher::Event E) { @@ -151,8 +153,10 @@ struct VerifyingConsumer { } else { ExpectedNonInitial.erase(It); } - if (result()) + if (result()) { + L.unlock(); ResultIsReady.notify_one(); + } } // This method is used by DirectoryWatcher. |