Lines Matching refs:ylong_runtime
1 # ylong_runtime 用户指南
3 ylong_runtime提供了异步任务生成以及调度的能力,同时异步化了各类系统IO,并提供了同步原语,定时器功能。
5 ylong_runtime 整体分为4个库:
9 - ylong_runtime: 异步调度框架库
12 其中 ylong_runtime 承载了异步调度框架的主体功能,并且依赖其余三个库提供的底层能力。
18 可以链式设置runtime的具体配置。必须在`block_on`,`spawn`之前设置,否则`runtime`会使用默认配置。 相关接口位于`ylong_runtime::builder`.
22 let _ = ylong_runtime::builder::RuntimeBuilder::new_multi_thread()
30 let _ = ylong_runtime::block_on(fut);
40 let handle = ylong_runtime::spawn(async move {
42 let handle = ylong_runtime::spawn(async move {
52 let res = ylong_runtime::block_on(handle).unwrap();
66 let join_handle = ylong_runtime::spawn_blocking(|| {});
70 let _ = ylong_runtime::block_on(fut);
81 use ylong_runtime::error::ErrorKind;
82 use ylong_runtime::time::sleep;
85 let handle = ylong_runtime::spawn(async move {
86 let task = ylong_runtime::spawn(async move {
93 ylong_runtime::block_on(handle).unwrap();
99 使用 ylong_runtime 中封装的异步IO(TCP/UDP)进行网络连接,相关接口定义位于模块 `ylong_runtime::net`.
102 use ylong_runtime::net::{TcpListener, TcpStream};
103 use ylong_runtime::io::AsyncWrite;
107 let handle = ylong_runtime::spawn(async move {
133 定时器相关接口位于模块`ylong_runtime::time`. 里面包括了任务睡眠,任务超时,以及周期性定时器的功能。
137 use ylong_runtime::time::{timeout, sleep};
140 let handle = ylong_runtime::spawn(async move {
156 `ParIter` 及其相关接口定义于模块 `ylong_runtime::iter`,`ParIter`支持数据在线程中做并行迭代,一组数据会在线程中被分割,分割后的数据会在线程中并行执行迭代器中…
159 use ylong_runtime::iter::prelude::*;
162 ylong_runtime::block_on(fut());