pi_async_rt/
lib.rs

1//! # 基于Future(MVP),用于为外部提供基础的通用异步运行时和工具
2//!
3//! ## 主要特征
4//! - 可定制的[任务池],
5//! - 外部使用[任务ID]可以很方便的[唤醒]和[挂起]
6//! - 抽象接口,可以自由实现自己的[运行时],
7//! - [单线程运行时推动]可以由自己推动运行。
8//!
9//! [任务池]: rt/trait.AsyncTaskPool.html
10//! [任务ID]: rt/struct.TaskId.html
11//! [运行时]: rt/trait.AsyncRuntime.html
12//! [单线程运行时推动]: rt/single_thread/struct.SingleTaskRunner.html#method.run
13//! [唤醒]: rt/trait.AsyncRuntime.html#tymethod.wakeup
14//! [挂起]: rt/trait.AsyncRuntime.html#tymethod.pending
15//!
16//! # Examples
17//!
18//! 本地异步运行时:
19//! ```
20//! use pi_async::rt::{AsyncRuntime, AsyncRuntimeExt, serial_local_thread::{LocalTaskRunner, LocalTaskRuntime}};
21//! let rt = LocalTaskRunner::<()>::new().into_local();
22//! let _ = rt.block_on(async move {});
23//! ```
24//!
25//! 多线程异步运行时使用:
26//! ```
27//! use pi_async::prelude::{MultiTaskRuntime, MultiTaskRuntimeBuilder, StealableTaskPool};
28//! use pi_async::rt::AsyncRuntimeExt;
29//!
30//! let pool = StealableTaskPool::with(4,100000,[1, 254],3000);
31//! let builer = MultiTaskRuntimeBuilder::new(pool)
32//!     .set_timer_interval(1)
33//!     .init_worker_size(4)
34//!     .set_worker_limit(4, 4);
35//! let rt = builer.build();
36//! let _ = rt.spawn(async move {});
37//! ```
38//!
39//! # Features
40//!
41//! - ```serial```: 用于开启单线程顺序任务
42
43#![allow(warnings)]
44#![feature(panic_info_message)]
45#![feature(allocator_api)]
46#![feature(alloc_error_hook)]
47#![feature(thread_id_value)]
48#![feature(negative_impls)]
49#![feature(panic_payload_as_str)]
50
51pub mod lock;
52pub mod prelude;
53pub mod rt;