I would like to use MPSCAsyncChannel as following:
private final class ShardedData: Sendable {
typealias Channel = MultiProducerSingleConsumerAsyncChannel<Int, Never>
let shards: UniqueArray<Channel.Source>
func send(idx: Int, value: Int) async throws {
try await shards[idx].send(value)
}
}
Unfortunately Source is mutating on send() and non-sendable itself.
I wonder if that is intentional and if it is safe to workaround it wrapping into @uncheked Sendable class:
private final class ShardedData: Sendable {
typealias Channel = MultiProducerSingleConsumerAsyncChannel<Int, Never>
final class SourceWrap: @unchecked Sendable {
var source: Channel.Source
init(source: consuming Channel.Source) {
self.source = source
}
}
let shards: UniqueArray<SourceWrap>
func send(idx: Int, value: Int) async throws {
try await shards[idx].source.send(value)
}
}
or/and as:
private nonisolated(unsafe) var shards: UniqueArray<Channel.Source>
I would like to use MPSCAsyncChannel as following:
Unfortunately Source is mutating on send() and non-sendable itself.
I wonder if that is intentional and if it is safe to workaround it wrapping into
@uncheked Sendableclass:or/and as: