&self.dep_graph
}
- fn read_query_job<R>(&self, op: impl FnOnce(Option<QueryJobId<Self::DepKind>>) -> R) -> R {
- tls::with_related_context(*self, move |icx| op(icx.query))
+ fn current_query_job(&self) -> Option<QueryJobId<Self::DepKind>> {
+ tls::with_related_context(*self, |icx| icx.query)
}
fn try_collect_active_jobs(
fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
/// Get the query information from the TLS context.
- fn read_query_job<R>(&self, op: impl FnOnce(Option<QueryJobId<Self::DepKind>>) -> R) -> R;
+ fn current_query_job(&self) -> Option<QueryJobId<Self::DepKind>>;
fn try_collect_active_jobs(
&self,
let query_map = tcx.try_collect_active_jobs().unwrap();
// Get the current executing query (waiter) and find the waitee amongst its parents
- let mut current_job = tcx.read_query_job(|query| query);
+ let mut current_job = tcx.current_query_job();
let mut cycle = Vec::new();
while let Some(job) = current_job {
impl<CTX: QueryContext> QueryLatch<CTX> {
/// Awaits for the query job to complete.
pub(super) fn wait_on(&self, tcx: CTX, span: Span) -> Result<(), CycleError<CTX::Query>> {
- tcx.read_query_job(move |query| {
- let waiter = Lrc::new(QueryWaiter {
- query,
- span,
- cycle: Lock::new(None),
- condvar: Condvar::new(),
- });
- self.wait_on_inner(&waiter);
- // FIXME: Get rid of this lock. We have ownership of the QueryWaiter
- // although another thread may still have a Lrc reference so we cannot
- // use Lrc::get_mut
- let mut cycle = waiter.cycle.lock();
- match cycle.take() {
- None => Ok(()),
- Some(cycle) => Err(cycle),
- }
- })
+ let query = tcx.current_query_job();
+ let waiter =
+ Lrc::new(QueryWaiter { query, span, cycle: Lock::new(None), condvar: Condvar::new() });
+ self.wait_on_inner(&waiter);
+ // FIXME: Get rid of this lock. We have ownership of the QueryWaiter
+ // although another thread may still have a Lrc reference so we cannot
+ // use Lrc::get_mut
+ let mut cycle = waiter.cycle.lock();
+ match cycle.take() {
+ None => Ok(()),
+ Some(cycle) => Err(cycle),
+ }
}
}
let global_id = QueryJobId::new(id, lookup.shard, Q::DEP_KIND);
- let job = tcx.read_query_job(|query| QueryJob::new(id, span, query));
+ let job = tcx.current_query_job();
+ let job = QueryJob::new(id, span, job);
entry.insert(QueryResult::Started(job));