-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(watch): simplify watch data synchronization #9154
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
8 Skipped Deployments
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewer's guide
let changed_packages_guard = changed_packages.lock().await; | ||
if !changed_packages_guard.borrow().is_empty() { | ||
let changed_packages = changed_packages_guard.take(); | ||
let some_changed_packages = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only acquire the guard in the block so we ensure we release the lock once we take the changed packages. This lets the event_fut
make progress while self.execute_run
is pending.
(!changed_packages_guard.is_empty()) | ||
.then(|| std::mem::take(changed_packages_guard.deref_mut())) | ||
}; | ||
if let Some(changed_packages) = some_changed_packages { | ||
self.execute_run(changed_packages).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed_packages_guard
is still held while run is being executed, this prevents any events from being handled.
Description
Basic view of the futures involved with running
watch
events_fut
takes events from the package changes watcher and folds them into aChangedPackages
struct. It then triggers a notify.run_fut
loops waiting for a notification and then performing a run.SIGINT
sThis PR cleans up how packages changes are synchronized between futures:
RefCell
asMutex
already implies mutually exclusive access the the underlying resourcerun_fut
holding onto the changed packages lock for the entirety of it's run. This allows us to switch fromtokio::sync::Mutex
tostd::sync::Mutex
. Which is suggested by thetokio::sync::Mutex
docsTesting Instructions
rustc
+ 👀 . Quick gut check by runningturbo watch
and triggering package changes