[PATCH] D55359: [clangd] Avoid emitting Queued status when we are able to acquire the Barrier.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 7 07:49:38 PST 2018


hokein added inline comments.


================
Comment at: clangd/TUScheduler.cpp:644
+      std::unique_lock<Semaphore> Lock(Barrier, std::try_to_lock);
+      if (Lock.owns_lock()) {
+        ExecuteAction();
----------------
ilya-biryukov wrote:
> 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.
ah, good point.


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