 		generatorDisposable = generator(observer)
 	}
 
+	/// Swap the generator disposable with `nil`.
+	///
+	/// - returns:
+	///   The generator disposable, or `nil` if it has been disposed of.
 	@inline(__always)
 	private func swapDisposable() -> Disposable? {
 		if let d = generatorDisposable {


				signal.sendLock.lock()

				if case .green = signal.status {
					for observer in observers {
						observer.action(event)
					}

					// Check if a downstream consumer or a concurrent sender has
					// interrupted the signal.
					if case let .yellow(state) = signal.status {
						state.send()
						signal.status = .red
						shouldDispose = true
					}
				}

				signal.sendLock.unlock()

				// Based on the implicit memory order, any updates to the
				// `terminationSnapshot` should always be visible after `sendLock` is
				// released. So we check it again and handle the termination if
				// it has not been taken over.
				if !shouldDispose, case let .yellow(state) = signal.status {
					signal.sendLock.lock()

					// The status check before acquring `sendLock` could be a false
					// positive, since it might race against other concurrent senders
					// until the lock acquisition above succeeds. So we have to check
					// again if the signal is still at `yellow`.
					if case .yellow = signal.status {
						state.send()
						signal.status = .red
						shouldDispose = true
					}


					// So we do not need to guard it with an explicit lock.
					//
					// Specifically, senders are serialized by `sendLock`, and can react
					// to and bump the status to `terminated` only after they see the
					// status being `terminating`.
					//
					// `terminating` can happen only once in the lifetime of a `Signal`,
					// since `state` being swapped with `nil` is a point of no return.
					//
					// Even in the case that both a previous sender and its successor see
					// `terminating`, the senders are still bound to the `sendLock`. So
					// whichever sender loses the battle of acquring `sendLock` is
					// guaranteed to see a status of `terminated`, and eventually be
					// blocked.
					signal.status = .terminating(SignalTerminationSnapshot(state: state, event: event))

					if signal.sendLock.try() {
						if case let .terminating(state) = signal.status {
							state.send()
							signal.status = .terminated
						}
						signal.sendLock.unlock()
						signal.swapDisposable()?.dispose()
