This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by hokein on Dec 6 2018, 2:31 AM.

Event Timeline

hokein created this revision.Dec 6 2018, 2:31 AM
ilya-biryukov added inline comments.Dec 7 2018, 6:16 AM
clangd/TUScheduler.cpp
652

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.

hokein updated this revision to Diff 177220.Dec 7 2018, 7:49 AM
hokein marked 2 inline comments as done.

Address review comment.

clangd/TUScheduler.cpp
652

ah, good point.

This revision is now accepted and ready to land.Dec 13 2018, 1:21 AM
This revision was automatically updated to reflect the committed changes.