Skip to content

Modern Swift concurrency#2

Merged
RISCfuture merged 1 commit into
mainfrom
modern-concurrency
Jun 27, 2026
Merged

Modern Swift concurrency#2
RISCfuture merged 1 commit into
mainfrom
modern-concurrency

Conversation

@RISCfuture

Copy link
Copy Markdown
Contributor

Summary

Adopts the Approachable Concurrency upcoming features for the GameGenerator
executable and modernizes the remaining legacy-concurrency sites so the package
is free of MainActor.run, GCD-as-concurrency, and dead imports.

  • Enables NonisolatedNonsendingByDefault and InferIsolatedConformances on the
    executable target.
  • Replaces the MainActor.run write-lock around stream writes with an
    actor-isolated append(_:) on GameFinder, and hoists the JSONEncoder into a
    stored, init-once property so the concurrent task-group children serialize their
    output through the actor instead of bouncing to the main actor.
  • Removes the unused import Dispatch from GameFinder.
  • Reworks the SIGINT (Ctrl-C) handler from a DispatchSource(queue: .main) +
    escaping closure + Self.exit() into an AsyncStream of interrupts bridged
    into a structured withThrowingTaskGroup, with cancellation observed in
    findGames. A Ctrl-C now cancels the search through structured cancellation,
    lets in-flight games finish streaming, and appends the closing ] before
    exiting cleanly. The DispatchSource signal source and signal(SIGINT, SIG_IGN)
    remain as the underlying primitive (there is no native async signal API); only
    their delivery is bridged to structured concurrency.

The command-line interface, JSON output format, and exit code are unchanged.

Verification

  • swift build --build-tests succeeds.
  • SwiftLint reports 0 violations.
  • This package has no unit-test or E2E targets. The SIGINT shutdown path was
    smoke-tested manually: clean exit code 0, well-formed bracketed JSON, and
    in-flight games flushed before exit.

🤖 Generated with Claude Code

…rrency

Enable the Approachable Concurrency upcoming features for the executable
target (NonisolatedNonsendingByDefault, InferIsolatedConformances) and
modernize the remaining legacy-concurrency sites so the package is free of
MainActor.run, GCD-as-concurrency, and dead imports.

- Replace the MainActor.run write-lock around stream writes with an
  actor-isolated append(_:) on GameFinder, and hoist the JSONEncoder into a
  stored, init-once property so the concurrent task-group children serialize
  their output through the actor instead of bouncing to the main actor.
- Drop the unused `import Dispatch` from GameFinder.
- Rework the SIGINT handler from a DispatchSource(queue: .main) + escaping
  closure + Self.exit() into an AsyncStream of interrupts bridged into a
  structured withThrowingTaskGroup, and observe cancellation in findGames so a
  Ctrl-C cancels the search, lets in-flight games finish streaming, and appends
  the closing `]` before exiting cleanly. The DispatchSource signal source and
  signal(SIGINT, SIG_IGN) remain as the underlying primitive since there is no
  native async signal API; only their delivery is bridged to structured
  concurrency.

The command-line interface, JSON output format, and exit code are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@RISCfuture RISCfuture force-pushed the modern-concurrency branch from 5e61f72 to bc73dd2 Compare June 27, 2026 08:09
@RISCfuture RISCfuture merged commit bc73dd2 into main Jun 27, 2026
4 checks passed
@RISCfuture RISCfuture deleted the modern-concurrency branch June 27, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant