Skip to content

Commit

Permalink
Avoid extra lock for subscriptions (#3476)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephen Celis <stephen@stephencelis.com>
  • Loading branch information
iampatbrown and stephencelis authored Nov 12, 2024
1 parent 8784f76 commit fdad435
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ final class CurrentValueRelay<Output>: Publisher {
}

func send(_ value: Output) {
self.lock.sync {
let subscriptions = self.lock.sync {
self.currentValue = value
return self.subscriptions
}
for subscription in self.lock.sync({ self.subscriptions }) {
for subscription in subscriptions {
subscription.receive(value)
}
}
Expand Down

0 comments on commit fdad435

Please sign in to comment.