-
Notifications
You must be signed in to change notification settings - Fork 61
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
Background task #365
Comments
I'm not sure |
Perhaps the symbol table data structure could be wrapped in an async fn background(&self) -> Result<()> {
// Wait for background task to complete, if any. If none, this
// should resolve immediately.
let _ = self.symbol_table.read().await;
// Spawn background task...
let mut symbol_table = self.symbol_table.clone();
tokio::spawn(async move {
let mut table = symbol_table.write().await;
// Update `table` here. Next call to `background()` will only be
// allowed to execute until after this guard is dropped.
});
// ...
} FYI @ratmice, I hope to relax the |
Thank you for your suggestion. |
Sure thing, @dalance! Feel free to post back with the results and if the behavior matches what you expect, and feel free to reopen the ticket if it doesn't resolve the issue. We can always iterate on ways to improve the experience going forward. |
I want to implement background task like symbol table construction of the entire project directory.
If I call the task in callback (ex.
did_changed
), the next callback can't be processed until finishing the task.Using
spawn
may resolve the problem, but communication between threads is not easy. So I prefer single thread.Is there a proper way?
I think the following interface may be useful, for example.
The text was updated successfully, but these errors were encountered: