use parking_lot::Mutex; use std::{any::Any, sync::LazyLock}; use tokio::sync::mpsc::{self, unbounded_channel}; type Anything = Box; static MAIN_DESTROY_QUEUE: LazyLock<( mpsc::UnboundedSender, Mutex>, )> = LazyLock::new(|| { let (tx, rx) = unbounded_channel(); (tx, Mutex::new(rx)) }); pub fn add(thing: T) { MAIN_DESTROY_QUEUE.0.send(Box::new(thing)).unwrap(); } pub fn clear() { while let Ok(thing) = MAIN_DESTROY_QUEUE.1.lock().try_recv() { drop(thing) } }