Skip to content

Commit 3e31c29

Browse files
committed
Make MPSCAsyncChannel source methods nonisolated(nonsending)
`nonisolated(nonsending)` is a 6.2 language feature that allows the inheritance of the callers isolation. The new `MPSCAsyncChannel.Source` send methods should adopt this to avoid unnecessary isolation hops.
1 parent 2773d41 commit 3e31c29

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/AsyncAlgorithms/MultiProducerSingleConsumerChannel/MultiProducerSingleConsumerAsyncChannel.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ extension MultiProducerSingleConsumerAsyncChannel {
456456
/// - Parameters:
457457
/// - sequence: The elements to send to the channel.
458458
@inlinable
459-
public mutating func send<S>(
459+
public mutating nonisolated(nonsending) func send<S>(
460460
contentsOf sequence: consuming sending S
461461
) async throws where Element == S.Element, S: Sequence, Element: Copyable {
462462
let syncSend: (sending S, inout Self) throws -> SendResult = { try $1.send(contentsOf: $0) }
@@ -493,7 +493,7 @@ extension MultiProducerSingleConsumerAsyncChannel {
493493
/// - Parameters:
494494
/// - element: The element to send to the channel.
495495
@inlinable
496-
public mutating func send(_ element: consuming sending Element) async throws {
496+
public mutating nonisolated(nonsending) func send(_ element: consuming sending Element) async throws {
497497
let syncSend: (consuming sending Element, inout Self) throws -> SendResult = { try $1.send($0) }
498498
let sendResult = try syncSend(element, &self)
499499

@@ -526,7 +526,7 @@ extension MultiProducerSingleConsumerAsyncChannel {
526526
/// - Parameters:
527527
/// - sequence: The elements to send to the channel.
528528
@inlinable
529-
public mutating func send<S>(contentsOf sequence: consuming sending S) async throws
529+
public mutating nonisolated(nonsending) func send<S>(contentsOf sequence: consuming sending S) async throws
530530
where Element == S.Element, S: AsyncSequence, Element: Copyable, S: Sendable, Element: Sendable {
531531
for try await element in sequence {
532532
try await self.send(contentsOf: CollectionOfOne(element))

0 commit comments

Comments
 (0)