Skip to content

Commit 8df6b75

Browse files
committed
Back Signal.Core.state with Atomic.
1 parent d6268d3 commit 8df6b75

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Sources/Signal.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ public final class Signal<Value, Error: Swift.Error> {
100100
/// Nevertheless, this should not cause the termination event being
101101
/// sent multiple times, since `tryTerminate` would not respond to false
102102
/// positives.
103-
private var state: State
103+
private var state: State {
104+
get { return _state.value }
105+
set { _state.value = newValue }
106+
}
107+
108+
private let _state: Atomic<State>
104109

105110
/// Used to ensure that state updates are serialized.
106111
private let updateLock: Lock
@@ -112,7 +117,7 @@ public final class Signal<Value, Error: Swift.Error> {
112117
private var hasDeinitialized: Bool
113118

114119
fileprivate init(_ generator: (Observer) -> Disposable?) {
115-
state = .alive(AliveState(observers: Bag()))
120+
_state = Atomic(.alive(AliveState(observers: Bag())))
116121

117122
updateLock = Lock.make()
118123
sendLock = Lock.make()

0 commit comments

Comments
 (0)