feat: add TaskManager::current (#5900)

This commit is contained in:
Matthias Seitz
2023-12-31 04:07:18 +01:00
committed by GitHub
parent 5b9817ae44
commit 4567252a72

View File

@ -162,6 +162,16 @@ pub struct TaskManager {
// === impl TaskManager ===
impl TaskManager {
/// Returns a a [TaskManager] over the currently running Runtime.
///
/// # Panics
///
/// This will panic if called outside the context of a Tokio runtime.
pub fn current() -> Self {
let handle = Handle::current();
Self::new(handle)
}
/// Create a new instance connected to the given handle's tokio runtime.
pub fn new(handle: Handle) -> Self {
let (panicked_tasks_tx, panicked_tasks_rx) = unbounded_channel();