mirror of
https://github.com/Noratrieb/the-good-stuff.git
synced 2026-01-14 16:45:01 +01:00
async
This commit is contained in:
parent
9bab547bcf
commit
8c59c7b3ae
28 changed files with 233 additions and 1306 deletions
23
async-experiments/tests/execute.rs
Normal file
23
async-experiments/tests/execute.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
use async_experiments::Executor;
|
||||
|
||||
#[test]
|
||||
fn execute() {
|
||||
let executor = Executor::new();
|
||||
|
||||
executor.block_on(async {});
|
||||
executor.block_on(async {});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn join2() {
|
||||
let exec = Executor::new();
|
||||
|
||||
let r = exec.block_on(async {
|
||||
let t1 = async_experiments::spawn_blocking(|| 1);
|
||||
let t2 = async_experiments::spawn_blocking(|| 2);
|
||||
|
||||
let (r1, r2) = async_experiments::join2(t1, t2).await;
|
||||
r1 + r2
|
||||
});
|
||||
assert_eq!(r, 3)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue