 	}
 
 	deinit {
-		if state.swap(nil) != nil {
-			// As the signal can deinitialize only when it has no observers attached,
-			// only the generator disposable has to be disposed of at this point.
+		// A signal can deinitialize only when it is not retained and has no
+		// active observers. So `state` need not be swapped.
+		//
+		// The generator disposable needs to be disposed of only if a `green` status
+		// is observed here, since `red` would mean it has already been disposed of,
+		// and `yellow` is impossible to be observed here.
+		if case .green = status {
 			generatorDisposable?.dispose()
 		}
 	}

	/// The state of the signal. `nil` if the signal has terminated.
	private let state: Atomic<SignalState<Value, Error>?>

	/// Initialize a Signal that will immediately invoke the given generator,
	/// then forward events sent to the given observer.
	///

	}
}

/// The status of a `Signal`.
private enum SignalStatus<Value, Error: Swift.Error> {
	/// The `Signal` is alive.
	case green

	/// The `Signal` has received a termination event, and is about to be
	/// terminated.
	case yellow(SignalTerminationSnapshot<Value, Error>)

	/// The `Signal` has terminated.
	case red
}

/// A snapshot of the state of a `Signal` when it receives a termination event.
///
/// - note: The snapshot must be a reference type, as the total size of all
///         stored properties might span beyond a cache line, resulting in
///         corrupted states being observed by the event emitter.
private final class SignalTerminationSnapshot<Value, Error: Swift.Error> {
	private let state: SignalState<Value, Error>
	private let event: Event<Value, Error>

