mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Previously, `SwiftASTManager` and `SlowRequestSimulator` maintained their own list of in-progress cancellation tokens. With code completion cancellation coming up, there would need to be yet another place to track in-progress requests, so let’s centralize it. While at it, also support cancelling requests before they are scheduled, eliminating the need for a `sleep` in a test case. The current implementaiton leaks tiny amounts of memory if a request is cancelled after if finishes. I think this is fine because it is a pretty nieche case and the leaked memory is pretty small (a `std::map` entry pointing to a `std::function` + `bool`). Alternatively, we could require the client to always dispose of the cancellation token manually.
10 lines
268 B
Swift
10 lines
268 B
Swift
// Check that we can cancel requests.
|
|
|
|
// RUN: not %sourcekitd-test -req=cursor -id=slow -async -pos=7:5 -simulate-long-request=5000 %s -- %s == \
|
|
// RUN: -cancel=slow 2>&1 \
|
|
// RUN: | %FileCheck %s
|
|
|
|
let x = "Hello World"
|
|
|
|
// CHECK: error response (Request Cancelled)
|