Description
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 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.
swift-nio/Sources/NIOConcurrencyHelpers/NIOLockedValueBox.swift
Lines 35 to 39 in 9ff5fdd
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
.