jextract/jni: Propagate CompletableFuture cancellation to Swift tasks

オープン
#947 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
54/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java, swift
領域
mobile-dev

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Swift
スター
1.3k
フォーク
127
平均マージ
2日 14時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

swiftlang/swift-java のほかの issue

swiftlang/swift-java の issue をすべて見る

似ている issue

Swift の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。