Skip to content

Commit

Permalink
fix tokio handle
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Oct 7, 2024
1 parent aac103e commit 0952c13
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
4 changes: 4 additions & 0 deletions turbopack/crates/turbo-tasks-fs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ impl DiskFileSystem {
pub fn invalidate(&self) {
let _span = tracing::info_span!("invalidate filesystem", path = &*self.root).entered();
let span = tracing::Span::current();
let handle = tokio::runtime::Handle::current();
let invalidator_map = take(&mut *self.invalidator_map.lock().unwrap());
let dir_invalidator_map = take(&mut *self.dir_invalidator_map.lock().unwrap());
let iter = invalidator_map
Expand All @@ -283,6 +284,7 @@ impl DiskFileSystem {
.flat_map(|(_, invalidators)| invalidators.into_par_iter());
iter.for_each(|i| {
let _span = span.clone().entered();
let _guard = handle.enter();
i.invalidate()
});
self.serialization_invalidator.invalidate();
Expand All @@ -291,6 +293,7 @@ impl DiskFileSystem {
pub fn invalidate_with_reason(&self) {
let _span = tracing::info_span!("invalidate filesystem", path = &*self.root).entered();
let span = tracing::Span::current();
let handle = tokio::runtime::Handle::current();
let invalidator_map = take(&mut *self.invalidator_map.lock().unwrap());
let dir_invalidator_map = take(&mut *self.dir_invalidator_map.lock().unwrap());
let iter = invalidator_map
Expand All @@ -305,6 +308,7 @@ impl DiskFileSystem {
});
iter.for_each(|(reason, invalidator)| {
let _span = span.clone().entered();
let _guard = handle.enter();
invalidator.invalidate_with_reason(reason)
});
self.serialization_invalidator.invalidate();
Expand Down
26 changes: 20 additions & 6 deletions turbopack/crates/turbo-tasks-fs/src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,10 @@ impl DiskWatcher {
let dir_invalidator_map = take(&mut *dir_invalidator_map.lock().unwrap());
let iter = invalidator_map
.into_par_iter()
.chain(dir_invalidator_map.into_par_iter())
.flat_map(|(path, invalidators)| {
.chain(dir_invalidator_map.into_par_iter());
let handle = tokio::runtime::Handle::current();
if report_invalidation_reason.is_some() {
iter.flat_map(|(path, invalidators)| {
let _span = span.clone().entered();
let reason = WatchStart {
name: name.clone(),
Expand All @@ -196,11 +198,23 @@ impl DiskWatcher {
invalidators
.into_par_iter()
.map(move |i| (reason.clone(), i))
})
.for_each(|(reason, invalidator)| {
let _span = span.clone().entered();
let _guard = handle.enter();
invalidator.invalidate_with_reason(reason)
});
iter.for_each(|(reason, invalidator)| {
let _span = span.clone().entered();
invalidator.invalidate_with_reason(reason)
});
} else {
iter.flat_map(|(_, invalidators)| {
let _span = span.clone().entered();
invalidators.into_par_iter().map(move |i| i)
})
.for_each(|invalidator| {
let _span = span.clone().entered();
let _guard = handle.enter();
invalidator.invalidate()
});
}
serialization_invalidator.invalidate();
}

Expand Down

0 comments on commit 0952c13

Please sign in to comment.