Skip to content

Add structured borrowed Kernel.Thread execution - #17

Closed
coenttb wants to merge 2 commits into
kernel-descriptor-span-iofrom
kernel-thread-structured-run
Closed

coenttb wants to merge 2 commits into
kernel-descriptor-span-iofrom
kernel-thread-structured-run

Conversation

@coenttb

@coenttb coenttb commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add synchronous Kernel.Thread.run for borrowed Sendable & ~Copyable & ~Escapable input
  • transfer the nonescaping operation and its disconnected capture region with sending through the existing consuming-transfer spawn overload, removing the public @Sendable operation requirement
  • return a sending move-only output with exact typed creation, join, and operation failures
  • confine the audited withoutActuallyEscaping bridge to the deepest Kernel.Thread implementation
  • add source-law fixtures for escaping, aliasing, non-Sendable input, and positive/negative move-only transfer

Structured safety law

The input borrow remains scoped until physical join on every path. The operation and its disconnected capture region move into the worker context and are consumed exactly once. The actual escaping OS-thread entry body is captureless and therefore @Sendable. Input: Sendable remains necessary because a borrow does not disconnect unrelated aliases; physical join bounds lifetime but cannot prevent concurrent access through those aliases. The result endpoint moves with the context and output returns as sending.

Control boundary

No generic thread-cancellation API is added. A higher owner may capture a caller-retained, synchronized, operation-specific endpoint in both the operation and a task cancellation handler. That is genuine concurrent sharing: Swift cancellation handlers are unavoidably @Sendable, and the endpoint must itself own precise wake semantics. No portable thread primitive can interrupt an arbitrary blocking syscall safely.

Stack

This draft is stacked on #15 at exact base f12f7def2eb02bd910d7e5e8d72160216f92b078; it does not broaden that pull request.

Verification

UNVERIFIED under the active source/static-only moratorium. No build, test, resolve, update, clean, run, compose, typecheck, lint, compiler probe, CI read, or Package.resolved mutation was performed.

@coenttb

coenttb commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

Semantic owner link (swift-institute/.github#591): this open PR implements swift-foundations/swift-kernel#16. Exact PR head at adjudication: 046fa86.

@coenttb
coenttb deleted the branch kernel-descriptor-span-io September 3, 2026 14:23
@coenttb coenttb closed this Sep 3, 2026
@coenttb
coenttb deleted the kernel-thread-structured-run branch September 3, 2026 14:23
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