Skip to content

Commit 09682d5

Browse files
committed
Switch from LockedState to Mutex for NotificationCenter.registrar
1 parent 21a0499 commit 09682d5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/FoundationEssentials/NotificationCenter/NotificationCenter.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ extension NotificationCenter {
2222

2323
#if !FOUNDATION_FRAMEWORK
2424

25+
internal import Synchronization
26+
2527
// Dictionary storage with automatic key generation
2628
private struct AutoDictionary<Value> {
2729
private var storage: [UInt64: Value] = [:]
@@ -75,11 +77,11 @@ private struct MessageBox {
7577
}
7678

7779
open class NotificationCenter: @unchecked Sendable {
78-
private var registrar: LockedState<[String? /* Notification name */: [ObjectIdentifier? /* object */ : AutoDictionary<@Sendable (MessageBox) -> Void>]]>
80+
private let registrar: Mutex<[String? /* Notification name */: [ObjectIdentifier? /* object */ : AutoDictionary<@Sendable (MessageBox) -> Void>]]>
7981
internal lazy var _actorQueueManager = _NotificationCenterActorQueueManager()
8082

8183
public required init() {
82-
registrar = LockedState(initialState: [:])
84+
registrar = .init([:])
8385
}
8486

8587
open class var `default`: NotificationCenter {

0 commit comments

Comments
 (0)