bach/
lib.rs

1#![doc = include_str!("../README.md")]
2
3extern crate alloc;
4
5#[macro_use]
6mod tracing;
7#[macro_use]
8pub mod metrics;
9
10pub mod coop;
11pub mod environment;
12pub mod executor;
13pub mod ext;
14pub mod group;
15#[cfg(feature = "net")]
16pub mod net;
17pub mod queue;
18pub mod rand;
19pub mod runtime;
20pub mod scope;
21pub mod sync;
22pub mod task;
23pub mod time;
24
25pub use task::spawn;
26
27/// Returns `true` if the caller is being executed in a `bach` environment
28pub fn is_active() -> bool {
29    task::scope::try_borrow_with(|scope| scope.is_some())
30}
31
32/// Runs a simulation using the default environment
33pub fn sim<F: FnOnce() -> R, R>(f: F) -> R {
34    let mut rt = environment::default::Runtime::new();
35    rt.run(f)
36}