Skip to content

Make endpoint types sendable - #80

Open
porchdog wants to merge 4 commits into
mainfrom
porchdog/endpoint-type-sendable
Open

Make endpoint types sendable#80
porchdog wants to merge 4 commits into
mainfrom
porchdog/endpoint-type-sendable

Conversation

@porchdog

Copy link
Copy Markdown

Adds Sendability conformance to Endpoint.EndpointType enum. This was mostly mechanical save for BonjourEndpoint and ApplicationServiceEndpoint which needed locking support to protect access to the mutable Storage object.

Comment thread Sources/SwiftNetwork/Endpoint/ApplicationServiceEndpoint.swift Outdated
@rnro rnro added the 🆕 semver/minor Adds new public API. label Aug 13, 2026
Comment thread Sources/SwiftNetwork/Endpoint/BonjourEndpoint.swift Outdated

@agnosticdev agnosticdev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@rnro rnro added 🆕 semver/minor Adds new public API. and removed 🆕 semver/minor Adds new public API. labels Aug 13, 2026
@rnro

rnro commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

The way that this pattern (a class-backed-struct) is made Sendable in the NIO family of repositories is to use the CoW as the concurrency protection by avoiding shared mutable state. The struct is then marked as @unchecked Sendable (not ideal but still required I think) e.g. https://github.com/apple/swift-nio/blob/48119dbbd23e3eabba48952ac7f75ebeeb87c217/Sources/NIOCore/ByteBuffer-core.swift#L1483 .

I suspect that we want to take that approach here since we are already using the NIO CoW pattern.

@porchdog
porchdog force-pushed the porchdog/endpoint-type-sendable branch from 24a25e1 to fca6bd3 Compare August 14, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants