Skip to main content

beam/
lib.rs

1// Global allocator — mimalloc.
2//
3// mimalloc is a compact general-purpose allocator by Microsoft with excellent
4// performance characteristics. It uses per-thread heap segments with deferred
5// freeing, reducing contention and fragmentation compared to glibc's malloc.
6//
7// Enabled by default on native targets via the `mimalloc` feature. Disabled on
8// WASM (no system allocator to replace) and when the feature is turned off.
9//
10// To use the system allocator instead: `cargo build --no-default-features --features native`
11#[cfg(all(feature = "mimalloc", not(target_arch = "wasm32")))]
12#[global_allocator]
13static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
14
15pub mod ack;
16pub mod actor;
17pub mod adapters;
18mod dup;
19pub mod mailbox;
20#[doc(hidden)]
21pub mod message; // pub for benchmarking
22pub mod metrics;
23mod tokio_spawn;
24mod tokio_time;
25
26#[cfg(not(target_arch = "wasm32"))]
27pub mod migration;
28
29mod node;
30mod router;
31#[cfg(feature = "webrtc")]
32mod stun;
33pub mod types;
34mod utils;
35pub use dup::Dup;
36pub mod sea;
37pub use node::{Config, Node};
38pub use types::Value;
39
40#[cfg(target_arch = "wasm32")]
41pub mod wasm;
42
43#[cfg(all(target_arch = "wasm32", test))]
44mod wasm_tests;
45// Include README.md as doctests — all ```rust code blocks in README are
46// compiled and run when `cargo test --doc` (or `cargo test`) is executed.
47// The struct only exists during doctest collection, so it's invisible in
48// the public API and has zero runtime cost.
49#[cfg(not(target_arch = "wasm32"))]
50#[doc = include_str!("../README.md")]
51#[cfg(doctest)]
52pub struct ReadmeDoctests;