You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4fb2294
Browse filesBrowse the repository at this point in the historyBrowse files
SciJava has accumulated several cancellation APIs -- Cancelable in
SciJava Common and ImageJ Ops, the cancel half of task.Task, Appose's
cancel() -- and SciJava Ops shipped with none of them. Rather than invent
a fourth, use the platform's: interruption as the mechanism, and
Future.cancel(true) as the API a caller holds.
Every scheme is cooperative, so that is not what distinguishes them;
composition is. An ambient thread flag is honored by code we did not
write, including every interruptible JDK blocking call, while an
isCanceled() interface only works for code that knows about it, and a
cancellation token pollutes every signature while still being unable to
abort a blocking call.
Note that an interrupt carries no reason: Thread.interrupt() takes no
argument and the JDK constructs InterruptedException with a null message.
A reason belongs to whoever requested cancellation, not to the exception.
Implemented here:
- Progress.checkCancellation() throws CancellationException, restoring
the interrupt flag first so code further up the stack still sees it.
Progress.update() calls it, so anything already reporting progress is
cancellable with no new API and no extra parameter. Ops cannot throw
InterruptedException, being plain Functions, hence the unchecked
CancellationException, which is also what Future.get() throws.
- DataHandles.copy checks the flag once per block and throws
InterruptedIOException, which is an IOException -- so the signature is
unchanged -- with bytesTransferred set to the partial copy. The
granularity matches the task.isCanceled() check it replaces; a read
already under way cannot be aborted, since plain streams are not
interruptible.
Cancelable is therefore not ported at all. The docs record the design,
its accepted limits (CompletableFuture.cancel does not interrupt; the
flag does not inherit to worker threads; native code ignores interrupts),
and why Appose's explicit cancel() stays as it is: interruption cannot
cross a process boundary.
Still to do: Parallelization and TaskExecutor must propagate cancellation
to worker futures, since the interrupt flag does not inherit.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013gJpzGd3ksbME4CN6Tu2ni
Copy file name to clipboardExpand all lines: docs/migration.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,7 +79,7 @@ A **dropped** row is a successful outcome, not a gap.
79
79
|`Locatable`| deferred — its only content was a default implementation needing `common3.Classes.location`, which `scijava-spi` cannot depend on | open |
80
80
|`Typed`| deferred to the plugin layer — no consumer yet, and `Class<T> type()` collides with `GenericTyped.type()`| open |
81
81
|`Initializable`|`scijava-context` (Phase 2) — a lifecycle hook, not an SPI contract | planned |
|`Cancelable`|**not ported** — cancellation is thread interruption, and the client API is `Future.cancel(true)`. See the cancellation section of [migration-plan.md](migration-plan.md)| dropped|
83
83
|`ItemIO`|`org.scijava.struct.ItemIO`| ported |
84
84
|`ItemVisibility`| input harvesting (Phase 4) | open |
0 commit comments