pub fn new(signal_source: impl Stream<Item = Option<Signal>> + Send + 'static) -> Self {
        // think about channel size
        let state = Arc::new(Mutex::new(HandlerState::default()));
        let worker_state = state.clone();
        let (close, mut rx) = mpsc::channel::<()>(1);
        tokio::spawn(async move {
            pin!(signal_source);
            tokio::select! {
                // We don't care if we get a signal or if we are unable to receive signals
                // Either way we start the shutdown.
                _ = signal_source.next() => {},
                // We don't care if a close message was sent or if all handlers are dropped.
                // Either way start the shutdown process.
                _ = rx.recv() => {}
            }

            let mut callbacks = {
                let mut state = worker_state.lock().expect("lock poisoned");
                // Mark ourselves as closing to prevent any additional subscribers from being
                // added
                state.is_closing = true;
                state
                    .subscribers
                    .drain(..)
                    .filter_map(|callback| {
                        let (tx, rx) = oneshot::channel();
                        // If the subscriber is no longer around we don't wait for the callback
                        callback.send(tx).ok()?;
                        Some(rx)
                    })
                    .collect::<FuturesUnordered<_>>()
            };

            // We don't care if callback gets dropped or if the done signal is sent.
            while let Some(_fut) = callbacks.next().await {}
        });

        Self { state, close }
    }
Construct a new SignalHandler that will alert any subscribers when
`signal_source` completes or `close` is called on it.
crates/turborepo-signals/src/lib.rs