-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SourceKit] Allow explicit cancellation of requests with a cancellation token #39494
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
[SourceKit] Allow explicit cancellation of requests with a cancellation token #39494
Conversation
@swift-ci Please smoke test |
tools/SourceKit/tools/sourcekitd/bin/InProc/sourcekitdInProc.cpp
Outdated
Show resolved
Hide resolved
tools/SourceKit/tools/sourcekitd/bin/InProc/sourcekitdInProc.cpp
Outdated
Show resolved
Hide resolved
tools/SourceKit/tools/sourcekitd/bin/XPC/Service/XPCService.cpp
Outdated
Show resolved
Hide resolved
95c3d7d
to
649f351
Compare
Thanks for your feedback @benlangmuir. I addressed the comments and also moved the
|
…on token The key changes here are - To keep track of cancellation tokens for all `ScheduledConsumer`s in `SwiftASTManager` - Generate unique request handles for all incoming requests (`create_request_handle `), use these request handles as cancellation tokens and return them from the `sourcekitd_send_request` methods - Implement cancellation with `sourcekitd_cancel_request` as the entry point and `SwiftASTManager::cancelASTConsumer` as the termination point Everything else is just plumbing the cancellation token through the various abstraction layers. rdar://83391505
649f351
to
fb26447
Compare
@swift-ci Please smoke test |
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.
LGTM!
// We need to wait a little bit after request scheduling and cancellation to make sure we are not cancelling the request before it got scheduled. | ||
|
||
// RUN: not %sourcekitd-test -req=cursor -id=slow -async -pos=10:3 %s -- %s == \ | ||
// RUN: -shell -- sleep 1 == \ |
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.
I thought this would need // REQUIRES: shell
, but I guess the tests passed on all platforms 🤷
The key changes here are
ScheduledConsumer
s inSwiftASTManager
create_request_handle
), use these request handles as cancellation tokens and return them from thesourcekitd_send_request
methodssourcekitd_cancel_request
as the entry point andSwiftASTManager::cancelASTConsumer
as the termination pointEverything else is just plumbing the cancellation token through the various abstraction layers.
rdar://83391505