Repository navigation
Conversation
Code that keeps one queue per key creates each queue on demand, and needs to know when it can remove a queue without breaking the order of the work enqueued on it. `isIdle` tells it. - `FIFOQueue.isIdle` is true when every task enqueued on the queue has finished: its operation has returned or thrown. A task that is suspended at an `await` hasn't finished, and neither has a cancelled task, which keeps its place and whose operation still runs. - `ActorQueue.isIdle` is true when every task enqueued on the queue has started running on the actor, so the operations of its tasks might not have finished. `MainActor.queue` gets it as an `ActorQueue`. A task counts from the moment `Task(on:)` enqueues it, before `Task(on:)` returns, and the value can change as soon as it is read. If one actor enqueues every task on a queue, it can read `isIdle` and then remove an idle queue, without suspending between the read and the removal: no task can be enqueued in between. For a `FIFOQueue`, work enqueued afterward on a new queue then runs after every task on the removed queue. The documentation and a new README section show this with an actor that keeps one `FIFOQueue` per document. The property adds no state and no work to the enqueue path. `Turns` already records the most recently reserved ticket, and a turn ends only after every earlier turn has ended, so `Turns.isIdle` reads `lastTicket?.hasEnded ?? true` under the lock that `reserve()` and `end()` take. `CancellableQueue` gets no `isIdle`. The caller creates the queue it wraps, so the caller can keep a reference to that queue and read its `isIdle`. The tests force each ordering with semaphores, an actor whose executor runs only when the test runs it, or by holding the main actor. They cover a new queue, a task that was just enqueued, a suspended operation in each of the four `FIFOQueue` initializers, a cancelled `FIFOQueue` task, several tasks, and an `ActorQueue` whose last operation hasn't finished, including on the main actor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HLuVQLsTNvRnyh155N25UM
In 1.x, an `ActorQueue` ran every operation inside one long-lived task, at the priority of the code that created the queue. In 2.0, each `Task(on: actorQueue)` is its own task, so an operation enqueued from low-priority code runs at low priority, and an `ActorQueue` had no way to give its tasks a priority of its own. `ActorQueue(priority:)` works like `FIFOQueue(priority:)`: it gives each of the queue's tasks at least that priority. A task that would run at a lower priority runs at the queue's priority instead, and a task enqueued at a higher priority keeps it. All four `Task(on:)` initializers for `ActorQueue` use it, and so do the four for a `CancellableQueue` that wraps an `ActorQueue`; their documentation now says so. `ActorQueue()` still compiles and gives its tasks no minimum priority. `MainActor.queue` has none either, which its documentation now says. The README's priority section and migration notes now point `ActorQueue` users to `ActorQueue(priority:)`. `FIFOQueue`'s code that works out a task's priority moves unchanged into an internal `MinimumPriority` type that both queues use, so `FIFOQueue` behaves exactly as before and its tests are unchanged. Without a minimum priority, the `ActorQueue` enqueue path adds one check of an optional. A task that runs at the queue's priority is escalated like any other task. New tests cover the minimum priority in each `ActorQueue` initializer, the priority a task inherits inside and outside of a task, and escalation of a task that runs at the queue's priority. The existing test of an explicit priority on an `ActorQueue` now covers four priorities in all four initializers, as `FIFOQueue`'s does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HLuVQLsTNvRnyh155N25UM
Not for merging. This measures how long a macOS job that builds and runs the test suite with Thread Sanitizer takes, and whether it reports anything. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HLuVQLsTNvRnyh155N25UM
Not for merging. Tries to download the iOS 18.5 simulator runtime with Xcode 27.2 and then with any older Xcode on the runner, and runs the tests on it with Xcode 27.2, timing each step. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HLuVQLsTNvRnyh155N25UM
Not for merging. Xcode 27.2 cannot download iOS 18.5 ("iOS 22F77 is
not available for download"), and the xcode-27 runner has only Xcode
27.x installed. This exports the runtime image with Xcode 26.1.1 on
macos-15, as main's CI downloads it, passes it to the xcode-27 runner as
an artifact, adds it with simctl, and runs the tests on it with Xcode
27.2, timing each step.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HLuVQLsTNvRnyh155N25UM
Not for merging. Xcode 26 may export a runtime as an .exportedBundle rather than a disk image. Import whatever the export produced with xcodebuild -importPlatform, fall back to simctl runtime add, and prebuild the dyld shared cache before the first boot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HLuVQLsTNvRnyh155N25UM
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## claude/2.0-11-actor-queue-priority #98 +/- ##
====================================================================
Coverage 100.00% 100.00%
====================================================================
Files 14 14
Lines 3098 3098
====================================================================
Hits 3098 3098 🚀 New features to boost your workflow:
|
|
"Build Xcode (visionOS)" failed before any test ran. The build succeeded, then This PR changes only CI files: the two spike jobs and their script. It doesn't change the library, the tests or the visionOS job. The same job passed on #97, the base, at the same library and test code (1626034). I'll re-run the failed job once when this run finishes. Generated by Claude Code |
Not for merging. On macos-15, Xcode 26.1.1 exports the preinstalled iOS 18.5 runtime to iphonesimulator_18.5_22F77.dmg in about 40 seconds, then exits with code 70 after "Unable to connect to simulator." Check that the disk image exists instead of trusting the exit code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HLuVQLsTNvRnyh155N25UM
Not for merging. The xcode-27 image holds 69 GB of simulator images, and adding the 9.1 GB iOS 18.5 image failed with "Cannot copy the image because the disk is almost full". Delete every runtime except the 27.2 one of each platform first, and log the free space and the time taken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HLuVQLsTNvRnyh155N25UM
Not for merging. xcodebuild -downloadPlatform -exportPath fails at random on macos-15 with "Unable to connect to simulator." The image already has iOS 18.5 installed as a disk image, so copy it from the path that simctl runtime list -j reports, and export only if it isn't there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HLuVQLsTNvRnyh155N25UM
1626034 to
9ba2419
Compare
|
The spike is done. #99 adds the macOS Thread Sanitizer job and the iOS 18 simulator jobs that this draft measured, and makes each simulator job run the suite once. Closing this draft. Generated by Claude Code |
Summary
A throwaway draft to measure a macOS Thread Sanitizer job. It adds one job, "Thread Sanitizer on macOS", to
ci.yml. The job runs on the samexcode-27runner and Xcode 27.2 as the other macOS jobs. It builds the package and its tests with--sanitize=thread, then runs the suite once.The questions it answers:
Turns.swiftthat look like false positives fromMutex's contended path.This PR will be closed once the run finishes. If the job is worth keeping, it will be added to the 2.0 series separately.
Generated by Claude Code