@@ -17,7 +17,7 @@ final class BoundedBufferStorage<Base: AsyncSequence>: Sendable where Base: Send
17
17
self . stateMachine = ManagedCriticalState ( BoundedBufferStateMachine ( base: base, limit: limit) )
18
18
}
19
19
20
- func next( ) async -> Result < Base . Element , Error > ? {
20
+ func next( ) async -> UnsafeTransfer < Result < Base . Element , Error > ? > {
21
21
return await withTaskCancellationHandler {
22
22
let action : BoundedBufferStateMachine < Base > . NextAction ? = self . stateMachine. withCriticalRegion {
23
23
stateMachine in
@@ -45,14 +45,14 @@ final class BoundedBufferStorage<Base: AsyncSequence>: Sendable where Base: Send
45
45
46
46
case . returnResult( let producerContinuation, let result) :
47
47
producerContinuation? . resume ( )
48
- return result
48
+ return UnsafeTransfer ( result)
49
49
50
50
case . none:
51
51
break
52
52
}
53
53
54
54
return await withUnsafeContinuation {
55
- ( continuation: UnsafeContinuation < Result < Base . Element , Error > ? , Never > ) in
55
+ ( continuation: UnsafeContinuation < UnsafeTransfer < Result < Base . Element , Error > ? > , Never > ) in
56
56
let action = self . stateMachine. withCriticalRegion { stateMachine in
57
57
stateMachine. nextSuspended ( continuation: continuation)
58
58
}
@@ -61,7 +61,7 @@ final class BoundedBufferStorage<Base: AsyncSequence>: Sendable where Base: Send
61
61
break
62
62
case . returnResult( let producerContinuation, let result) :
63
63
producerContinuation? . resume ( )
64
- continuation. resume ( returning: result)
64
+ continuation. resume ( returning: UnsafeTransfer ( result) )
65
65
}
66
66
}
67
67
} onCancel: {
@@ -109,6 +109,7 @@ final class BoundedBufferStorage<Base: AsyncSequence>: Sendable where Base: Send
109
109
case . none:
110
110
break
111
111
case . resumeConsumer( let continuation, let result) :
112
+
112
113
continuation. resume ( returning: result)
113
114
}
114
115
}
@@ -120,7 +121,7 @@ final class BoundedBufferStorage<Base: AsyncSequence>: Sendable where Base: Send
120
121
case . none:
121
122
break
122
123
case . resumeConsumer( let continuation) :
123
- continuation? . resume ( returning: nil )
124
+ continuation? . resume ( returning: UnsafeTransfer ( nil ) )
124
125
}
125
126
} catch {
126
127
let action = self . stateMachine. withCriticalRegion { stateMachine in
@@ -130,7 +131,7 @@ final class BoundedBufferStorage<Base: AsyncSequence>: Sendable where Base: Send
130
131
case . none:
131
132
break
132
133
case . resumeConsumer( let continuation) :
133
- continuation? . resume ( returning: . failure( error) )
134
+ continuation? . resume ( returning: UnsafeTransfer ( Result < Base . Element , Error > . failure ( error) ) )
134
135
}
135
136
}
136
137
}
@@ -148,7 +149,7 @@ final class BoundedBufferStorage<Base: AsyncSequence>: Sendable where Base: Send
148
149
case . resumeProducerAndConsumer( let task, let producerContinuation, let consumerContinuation) :
149
150
task. cancel ( )
150
151
producerContinuation? . resume ( )
151
- consumerContinuation? . resume ( returning: nil )
152
+ consumerContinuation? . resume ( returning: UnsafeTransfer ( nil ) )
152
153
}
153
154
}
154
155
0 commit comments