You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here, withLock needs to take its closure sending and the return value needs to be sending too. In Swift 5, these both need to be Sendable, with an unchecked version available.
Here, withLockedValue needs again to take its closure sending. Optionally, we could relax its Sendable requirement, and also return the value sending, but given our need to remain compatible with Swift 5 we should probably leave it stricter for now. In Swift 5, the closure probably needs to be @Sendable.
The text was updated successfully, but these errors were encountered:
@Lukasa Why does NIOLock.withLock need sending? It doesn't contain a value (so there's nothing to escape) and it never changes isolation or anything (no async etc).
And NIOLockedValueBox is currently only Sendable iff Value: Sendable, so that seems fine too as it can be escaped safely.
Said all that, it might be useful for developers if they were sending (just in case they want to pass an isolated closure). But I don't see a not-strict-enough issue here.
I think we should reverb this ticket as it's currently written confusingly. My summary would be:
Most importantly: NIOLockedValueBox as well as NIOLock are correct regarding sendability etc
NIOLock should stay is as and should not get a sending in withLock (as that would make it less useful)
NIOLockedValueBox is more strict than it needs to be as of Swift 6.0. It could be even more helpful if it took sending closures as that would allow us to make it unconditionally Sendable.
NIOLock is particularly scary, but NIOLockedValueBox has some limitations too that need to be tidied up.
The following functions are dangerous:
swift-nio/Sources/NIOConcurrencyHelpers/NIOLock.swift
Lines 232 to 254 in 9ff5fdd
Here,
withLock
needs to take its closuresending
and the return value needs to besending
too. In Swift 5, these both need to beSendable
, with an unchecked version available.swift-nio/Sources/NIOConcurrencyHelpers/NIOLockedValueBox.swift
Lines 35 to 39 in 9ff5fdd
Here,
withLockedValue
needs again to take its closuresending
. Optionally, we could relax itsSendable
requirement, and also return the valuesending
, but given our need to remain compatible with Swift 5 we should probably leave it stricter for now. In Swift 5, the closure probably needs to be@Sendable
.The text was updated successfully, but these errors were encountered: