Skip to content

Commit

Permalink
rt: add a method to determine if the runtime is multi-threaded.
Browse files Browse the repository at this point in the history
  • Loading branch information
agayev committed Oct 27, 2022
1 parent 32d68fe commit 1d69f96
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tokio/src/runtime/handle.rs
Expand Up @@ -101,6 +101,15 @@ impl Handle {
}
}

/// Returns true if the currently running `Runtime` is multi-threaded and
/// false otherwise.
pub fn is_multi_threaded(&self) -> bool {
match self.inner {
scheduler::Handle::CurrentThread(_) => false,
scheduler::Handle::MultiThread(_) => true,
}
}

/// Returns a Handle view over the currently running Runtime
///
/// Returns an error if no Runtime has been started
Expand Down

0 comments on commit 1d69f96

Please sign in to comment.