1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#![deny(unsafe_op_in_unsafe_fn, missing_docs)]
mod task;
mod task_pool;
use futures_lite::future;
pub use task::*;
pub use task_pool::*;
use std::future::Future;
#[inline]
pub fn spawn<T>(future: impl Future<Output = T> + Send + 'static) -> Task<T>
where
T: Send + 'static,
{
TaskPool::global().spawn(future)
}
#[inline]
pub fn spawn_local<T>(future: impl Future<Output = T> + 'static) -> Task<T>
where
T: 'static,
{
TaskPool::global().spawn_local(future)
}
#[inline]
pub fn scope<'env, F, T>(f: F) -> Vec<T>
where
F: for<'scope> FnOnce(&'scope Scope<'scope, 'env, T>),
T: Send + 'static,
{
TaskPool::global().scope(f)
}
#[inline]
pub fn block_on<T>(future: impl Future<Output = T>) -> T {
future::block_on(future)
}