Skip to content

Commit 33fb393

Browse files
core/task: describe the cancellation fence as what it is today
The fence comments asserted an effect no production reader produces yet: that the counter separates a cancelled run from the run that resumes afterwards, and that a write still parked on its path chain publishes after disposal. At this head cancellationGeneration has three production sites (the field and the two increments in requestAbort and requestDispose) and no production reader; nine assertions in src/core/task/__tests__/Task.spec.ts 4786-4851 are what pin it. The three blocks now say the counter is monotonic, that a future guarded write would compare the value it captured when queued with the value at publish time, and that no such write exists today. Comment-only: the non-comment content of src/core/task/Task.ts is byte-identical (sha256/16 60377E70665E7EE0 over 5,530 non-comment lines before and after), so the mutation gate prices 0 counted executable lines for this commit. Answered on Zoo-Code-Org/Zoo-Code pull request 2396, review thread 4520707090.
1 parent d0496c5 commit 33fb393

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

‎src/core/task/Task.ts‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,11 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
400400
// Monotonic cancellation fence. `requestAbort()` and `requestDispose()` advance it
401401
// on every cancellation and it never goes backwards: the run-state kernel has no
402402
// transition that clears `latches.abort`, so `abort` stays true across
403-
// `resumeAfterDelegation()`, and only this counter keeps a cancelled run apart
404-
// from the run that resumes afterwards. A guarded write would compare the value it
405-
// captured when the write was queued with the value at publish time; nothing
406-
// publishes through such a path today, so the counter has no production reader yet
407-
// and only its tests pin this behavior.
403+
// `resumeAfterDelegation()`, and this counter is what a future guarded write would
404+
// use to keep a cancelled run apart from the run that resumes afterwards. Such a
405+
// write would compare the value it captured when it was queued with the value at
406+
// publish time; no code publishes through that path today, so the counter has no
407+
// production reader and only its tests pin this behavior.
408408
cancellationGeneration: number = 0
409409
currentRequestAbortController?: AbortController
410410
/**
@@ -3610,11 +3610,11 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
36103610
this.abandoned = true
36113611
}
36123612
// Every cancellation must advance the fence, and it must never go backwards: the
3613-
// kernel never clears `latches.abort`, so a resumed run keeps `abort` true and
3614-
// only the counter separates the cancelled run from the resumed one.
3615-
// `driveRunEvent` below is the single cancellation entry point, and the
3616-
// guarded-write consumer documented at the field is what would compare this
3617-
// value across a queue hop.
3613+
// kernel never clears `latches.abort`, so a resumed run keeps `abort` true.
3614+
// `driveRunEvent` below is the single cancellation entry point. A guarded write
3615+
// would compare the value it captured here with the value at publish time, and
3616+
// that comparison is what would keep a cancelled run apart from the run that
3617+
// resumes afterwards; no code publishes through that path today.
36183618
this.cancellationGeneration++
36193619
this.driveRunEvent({ tag: "abortRequested", abandoned: isAbandoned })
36203620
}
@@ -3625,10 +3625,10 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
36253625
}
36263626

36273627
requestDispose(): void {
3628-
// A host teardown never calls `abortTask()`: disposal has to raise the same
3629-
// fence, or a write still parked on its path chain publishes after the task
3630-
// is gone. Same doctrine as `requestAbort`: the `disposeRequested` event below
3631-
// drives `abort` through the kernel, which never releases the latch.
3628+
// A host teardown never calls `abortTask()`, so disposal has to raise the same
3629+
// fence. The `disposeRequested` event below drives `abort` through the kernel,
3630+
// which never releases the latch. A guarded write parked on its path chain would
3631+
// compare against this value before publishing; no such write exists today.
36323632
this.cancellationGeneration++
36333633
this.driveRunEvent({ tag: "disposeRequested" })
36343634
}

0 commit comments

Comments
 (0)