[PATCH] D55359: [clangd] Avoid emitting Queued status when we are able to acquire the Barrier.
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 7 06:16:27 PST 2018
ilya-biryukov added inline comments.
================
Comment at: clangd/TUScheduler.cpp:644
+ std::unique_lock<Semaphore> Lock(Barrier, std::try_to_lock);
+ if (Lock.owns_lock()) {
+ ExecuteAction();
----------------
Maybe simplify the code a bit?
```
// Replacing these two lines:
// emitTUStatus({TUAction::Queued, Req.Name});
// std::lock_guard<Semaphore> BarrierLock(Barrier);
// With:
std::unique_lock<Semaphore> BarrierLock(Barrier, std::try_to_lock);
if (!Lock.owns_lock()) {
emitTUStatus({TUAction::Queued, Req.Name});
Lock.lock();
}
// Rest of the code is the same...
```
Avoids creating two locks and does not require helper lamdbas.
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55359/new/
https://reviews.llvm.org/D55359
More information about the cfe-commits
mailing list