feat: add README.md
This commit is contained in:
22
__concurrent/async_study/README.md
Normal file
22
__concurrent/async_study/README.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
Import `tokio`:
|
||||||
|
|
||||||
|
```
|
||||||
|
tokio = { version = "1.0", features = ["full"] }
|
||||||
|
```
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
// TODO ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
`tokio` 提供以下几种 channels 类型:
|
||||||
|
|
||||||
|
* mpsc: 多生产者,单消费者 - https://docs.rs/tokio/1/tokio/sync/mpsc/index.html
|
||||||
|
* oneshot: 单生产者,单消费者 - https://docs.rs/tokio/1/tokio/sync/oneshot/index.html
|
||||||
|
* broadcast: 多生产者,多消费者 - https://docs.rs/tokio/1/tokio/sync/broadcast/index.html
|
||||||
|
* watch: 单生产者,多消费者 - https://docs.rs/tokio/1/tokio/sync/watch/index.html
|
||||||
|
|
||||||
10
__concurrent/async_study/examples/async4.rs
Normal file
10
__concurrent/async_study/examples/async4.rs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
fn main() {
|
||||||
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||||
|
rt.block_on(async {
|
||||||
|
invoke().await
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn invoke() {
|
||||||
|
println!("Hello World!");
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user