Skip to content
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

Update BatchingDocumentGenerator to use AsyncBatchingWorkQueue #10158

Closed
DustinCampbell opened this issue Mar 25, 2024 · 0 comments · Fixed by #10140
Closed

Update BatchingDocumentGenerator to use AsyncBatchingWorkQueue #10158

DustinCampbell opened this issue Mar 25, 2024 · 0 comments · Fixed by #10140
Assignees

Comments

@DustinCampbell
Copy link
Member

No description provided.

@DustinCampbell DustinCampbell self-assigned this Mar 25, 2024
DustinCampbell added a commit that referenced this issue Mar 26, 2024
…#10140)

Fixes #10158

I recommend reviewing commit-by-commit.

Razor has had a `BatchingWorkQueue` for a long while that has dubious
semantics. It is used by three features:

- `OpenDocumentGenerator` - Listens for document updates, computes
generated output for each, and notifies listeners when a document has
been processed.
- `WorkspaceSemanticTokensRefreshPublisher` - Called in the server to
send the client `semanticTokens/refresh` notifications. This really sort
of abuses `BatchingWorkQueue` just for debouncing and only send
notifications every 250 milliseconds.
- `WorkspaceProjectStateChangeDetector` - Listens for Roslyn workspace
and Razor project manager changes and calls into
`IProjectWorkspaceStateGenerator.Update(...)` when a change occurs.

This change fully replaces `BatchingWorkQueue` with a copy of Roslyn's
`AsyncBatchingWorkQueue`, which has consistent semantics and has been
battle-hardened for years. I've updated `OpenDocumentGenerator` and
`WorkspaceProjectStateChangeDetector` above to use
`AsyncBatchingWorkQueue`. For `WorkspaceSemanticTokensRefreshPublisher`
(now `WorkspaceSemanticTokensRefreshNotifier`), I've removed the
`BatchingWorkQueue` altogether and replaced it with simpler logic that
debounces and calls `Task.Delay(...)`.

Many thanks to @CyrusNajmabadi for his help with
`AsyncBatchingWorkQueue`.

@dotnet/razor-compiler: The only relevant compiler changes are in shared
code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant