lelet/lib.rs
1//! Dynamic task executor.
2//!
3//! Inspired by golang runtime.
4//!
5//! It is okay to do blocking inside a task, the executor will
6//! detect this, and scale the thread pool.
7//!
8//! But, please keep note that every time you do blocking, it will
9//! create thread via [`thread::spawn`], and the number of thread you can create
10//! is not unlimited, so the number of blocking task you can [`spawn`] is also not unlimited
11//!
12//! [`thread::spawn`]: https://doc.rust-lang.org/std/thread/fn.spawn.html
13//! [`spawn`]: fn.spawn.html
14
15#[doc(hidden)]
16pub mod thread_pool;
17
18mod executor;
19pub use executor::spawn;
20pub use executor::JoinHandle;
21
22pub use executor::get_num_cpus;
23pub use executor::set_num_cpus;
24
25pub use lelet_utils::block_on;
26
27#[doc(hidden)]
28pub use executor::detach_current_thread;
29
30#[doc(hidden)]
31#[inline(always)]
32pub async fn yield_now() {
33 lelet_utils::Yields(1).await;
34}