Skip to content

Commit fdad435

Browse files
Avoid extra lock for subscriptions (#3476)
Co-authored-by: Stephen Celis <[email protected]>
1 parent 8784f76 commit fdad435

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Sources/ComposableArchitecture/Internal/CurrentValueRelay.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ final class CurrentValueRelay<Output>: Publisher {
3333
}
3434

3535
func send(_ value: Output) {
36-
self.lock.sync {
36+
let subscriptions = self.lock.sync {
3737
self.currentValue = value
38+
return self.subscriptions
3839
}
39-
for subscription in self.lock.sync({ self.subscriptions }) {
40+
for subscription in subscriptions {
4041
subscription.receive(value)
4142
}
4243
}

0 commit comments

Comments
 (0)