PreambleThrottlerRequest(llvm::StringRef Filename,
PreambleThrottler *Throttler,
std::condition_variable &CV)
- : Throttler(Throttler), Satisfied(Throttler == nullptr) {
+ : Throttler(Throttler),
+ Satisfied(Throttler == nullptr) {
// If there is no throttler, this dummy request is always satisfied.
if (!Throttler)
return;
+ Tracer.emplace("PreambleThrottled");
ID = Throttler->acquire(Filename, [&] {
Satisfied.store(true, std::memory_order_release);
CV.notify_all();
+ Tracer.reset();
});
}
}
private:
+ llvm::Optional<trace::Span> Tracer;
PreambleThrottler::RequestID ID;
PreambleThrottler *Throttler;
std::atomic<bool> Satisfied = {false};
if (Done)
break;
- Throttle.emplace(FileName, Throttler, ReqCV);
- // If acquire succeeded synchronously, avoid status jitter.
- if (!Throttle->satisfied())
- Status.update([&](TUStatus &Status) {
- Status.PreambleActivity = PreambleAction::Queued;
- });
- ReqCV.wait(Lock, [&] { return Throttle->satisfied() || Done; });
+ {
+ Throttle.emplace(FileName, Throttler, ReqCV);
+ llvm::Optional<trace::Span> Tracer;
+ // If acquire succeeded synchronously, avoid status jitter.
+ if (!Throttle->satisfied()) {
+ Tracer.emplace("PreambleThrottle");
+ Status.update([&](TUStatus &Status) {
+ Status.PreambleActivity = PreambleAction::Queued;
+ });
+ }
+ ReqCV.wait(Lock, [&] { return Throttle->satisfied() || Done; });
+ }
if (Done)
break;
// While waiting for the throttler, the request may have been updated!