jextract/jni: Propagate CompletableFuture cancellation to Swift tasks
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 54/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- mobile-dev
Research direction
Start by tracing the JNI async call and generated thenApply result-conversion stage described in the issue, then review the reference workaround in the linked pull request. Check how cancellation reaches the source future and the Swift task; done means cancelling the returned Java future forwards cancellation to the Swift task so cooperative operations such as Task.sleep can observe it.
Written by the indexing model from the issue text.
Description
Problem
Cancelling a future returned by a JNI async call currently changes only the Java future's state. The underlying Swift task keeps running. The generated thenApply result-conversion stage also prevents cancellation of the returned future from reaching the source future.
Example
public func waitForWork() async throws -> Int64 {
try await Task.sleep(for: .seconds(60))
return 1
}
A Java caller can cancel the returned future:
var future = MySwiftLibrary.waitForWork();
future.cancel(false);
The Java future is cancelled, but the Swift task continues running. Cancellation of the returned future should also be forwarded to the Swift task, so cancellation-aware operations such as Task.sleep can observe it.
Swift cancellation is cooperative: forwarding cancellation does not interrupt an operating-system thread or wait for the task to finish.
Reference workaround implementation: https://github.com/qoncept/swift-java/pull/10
- Dominant language
- Swift
- Stars
- 1.3k
- Forks
- 127
- Avg merge
- 1h 6m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from swiftlang/swift-java
-
Document main actor execution requirements in Java-hosted processesPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
swiftlang/swift-java#955 ·
Maintainers usually reply within 1 day
-
wrap-java: Optional convenience methods can fail to compile when a parameter shadows the method nameOpen
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
swiftlang/swift-java#945 ·
Maintainers usually reply within 1 day
-
android
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
swiftlang/swift-java#663 · 4 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 56/100
swiftlang/swift-java#949 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
swiftlang/swift-java#948 ·
Maintainers usually reply within 1 day
All issues in swiftlang/swift-java
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
JWhite212/SignalLadder#215 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
bug javascript
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
enhancement mac
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100