-
Notifications
You must be signed in to change notification settings - Fork 156
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
Make ServerProgressReport threadsafe #1130
Conversation
@@ -712,8 +713,7 @@ type AdaptiveFSharpLspServer | |||
|
|||
use progressReport = new ServerProgressReport(lspClient) | |||
|
|||
progressReport.Begin($"Loading {projects.Count} Projects") | |||
|> Async.StartImmediate | |||
progressReport.Begin($"Loading {projects.Count} Projects") (CancellationToken.None) |> ignore<Task<unit>> |
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.
callsite change to CancellableTask
// and https://gist.github.com/brendankowitz/5949970076952746a083054559377e56 | ||
type SemaphoreSlim with | ||
|
||
member x.LockAsync(?ct: CancellationToken) = |
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.
Helper so callers don't have to deal with fun try/finally semantics.
?cancellable = cancellable, | ||
?message = message, | ||
?percentage = percentage | ||
cancellableTask { |
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.
Switched to CancellableTask
since Async
doesn't know how to Await generic Awaitables.
2e12738
to
02461c5
Compare
02461c5
to
dc7f0bf
Compare
Noice 👍 The helpers are a wonderful thing to have. |
WHAT
🤖 Generated by Copilot at 2e12738
This pull request improves the cancellation and progress reporting of long-running tasks in the LSP servers. It introduces a new computation expression for
AdaptiveFSharpLspServer
and refactors the existing logic inFSharpLspClient
to use async tasks and semaphores.🤖 Generated by Copilot at 2e12738
🔄🚀🛠️
WHY
It's possible for the progress report to get out of sync with reality, it will show the progress dialogue box with no way to close it because it's possible to send Begin after End. This resolves that.
HOW
🤖 Generated by Copilot at 2e12738
cancellableTask
andlocker
semaphore for consistency and cancellation support (link, link, link)AwaitableDisposable
type andLockAsync
extension method forSemaphoreSlim
to handle async disposables safely and conveniently (link)System.Threading.Tasks
,System.Threading
, andIcedTasks
to useTask
,CancellationToken
, andcancellableTask
types and methods (link, link)