Skip to content

Commit 1aed887

Browse files
committed
Avoid extra lock for subscriptions
1 parent 3879d2c commit 1aed887

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Sources/ComposableArchitecture/Internal/CurrentValueRelay.swift

Lines changed: 3 additions & 2 deletions
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)