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
#[ allow(unused_imports) ]
use
{
futures_task :: { SpawnError, LocalFutureObj } ,
futures_util :: { task::{ LocalSpawnExt }, future::{ FutureExt, abortable } } ,
crate :: { JoinHandle } ,
std :: { pin::Pin, future::Future, sync::{ Arc, atomic::AtomicBool }, rc::Rc } ,
blanket :: { blanket } ,
};
#[ blanket(derive( Ref, Mut, Box, Arc, Rc )) ]
pub trait LocalSpawnHandle<Out: 'static>
{
fn spawn_handle_local_obj( &self, future: LocalFutureObj<'static, Out> ) -> Result<JoinHandle<Out>, SpawnError>;
}
pub trait LocalSpawnHandleExt<Out: 'static> : LocalSpawnHandle<Out>
{
fn spawn_handle_local( &self, future: impl Future<Output = Out> + 'static ) -> Result<JoinHandle<Out>, SpawnError>;
}
impl<T, Out> LocalSpawnHandleExt<Out> for T
where T : LocalSpawnHandle<Out> + ?Sized ,
Out: 'static ,
{
fn spawn_handle_local( &self, future: impl Future<Output = Out> + 'static ) -> Result<JoinHandle<Out>, SpawnError>
{
self.spawn_handle_local_obj( LocalFutureObj::new(future.boxed_local()) )
}
}