Why isn’t `ClientBootstrap` `Sendable`?

ClientBootstrap is apparently not Sendable, (even though swift-symbolgraph-extract seems to think otherwise).

#if swift(>=5.6)
@available(*, unavailable)
extension ClientBootstrap: Sendable {}
#endif

this means i cannot create one outside of an actor and pass it to the actor’s init, even though it will never be accessed concurrently.

why is ClientBootstrap not Sendable?

It is a class and doesn’t have any additional synchronisationen and therefore isn’t thread-safe.

2 Likes

i guess a better way to ask this question is then: why is ClientBootstrap a reference type in the first place?

of course i don’t know the details of how it’s implemented, but it seems to me at least that a ClientBootstrap is just a bag of settings and initialization functions, and shouldn’t really have any shared mutable state to begin with.

i can’t really think of many situations where it would be useful to add a setting to a ClientBootstrap and have those changes become visible to every other reference to that object.

You are right, ClientBootstrap should have been a struct. Sadly we can't change this without breaking API. Note that this would need some more redesign in the current implementation but AFAIK nothing fundamentally impossible in a new major version.

1 Like

Arguably, it could be made thread safe.