Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ extension MultiProducerSingleConsumerAsyncChannel {
}

@inlinable
func next(isolation: isolated (any Actor)? = #isolation) async throws -> Element? {
nonisolated(nonsending) func next() async throws -> Element? {
let action = self._stateMachine.withLock {
$0.next()
}
Expand Down Expand Up @@ -431,7 +431,7 @@ extension MultiProducerSingleConsumerAsyncChannel {
}

@inlinable
func suspendNext(isolation: isolated (any Actor)? = #isolation) async throws -> Element? {
nonisolated(nonsending) func suspendNext() async throws -> Element? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my recent testing, it seems nonisolated(nonsending) does not grant the ability to actually procure a reference to the isolated parameter in a way that allows isolating closures in the same manner that capturing an explicit isolated parameter does. i suppose in this case it doesn't matter since the parameter isn't being captured by the body closures, but that does make me wonder if those closures are actually not being isolated in the intended manner currently.

try await withTaskCancellationHandler {
try await withUnsafeThrowingContinuation { (continuation: UnsafeContinuation<Element?, Error>) in
let action = self._stateMachine.withLock {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ public struct MultiProducerSingleConsumerAsyncChannel<Element, Failure: Error>:
/// - Parameter isolation: The callers isolation.
/// - Returns: The next buffered element.
@inlinable
public mutating func next(
isolation: isolated (any Actor)? = #isolation
) async throws(Failure) -> Element? {
nonisolated(nonsending) public mutating func next() async throws(Failure) -> Element? {
do {
return try await self.storage.next()
} catch {
Expand Down Expand Up @@ -710,9 +708,7 @@ extension MultiProducerSingleConsumerAsyncChannel.ChannelAsyncSequence where Ele
}

@inlinable
mutating func next(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can change this one since this is a protocol requirement of AsyncSequence unless nonisolated(nonsending) methods are capable of fulfilling isolated protocol requirement

isolation actor: isolated (any Actor)? = #isolation
) async throws(Failure) -> Element? {
nonisolated(nonsending) mutating func next() async throws(Failure) -> Element? {
do {
return try await self._backing.storage.next(isolation: actor)
} catch {
Expand Down
Loading