11
11
) ]
12
12
13
13
use futures:: {
14
- compat:: Compat ,
15
- future:: { Future , FutureExt , FutureObj } ,
14
+ compat:: Future01CompatExt ,
15
+ future:: { BoxFuture , FutureExt , TryFutureExt } ,
16
16
task:: SpawnError ,
17
17
} ;
18
18
use lazy_static:: lazy_static;
@@ -34,7 +34,7 @@ use udp::UdpSocket;
34
34
pub struct Tokio ;
35
35
36
36
impl runtime_raw:: Runtime for Tokio {
37
- fn spawn_obj ( & self , fut : FutureObj < ' static , ( ) > ) -> Result < ( ) , SpawnError > {
37
+ fn spawn_boxed ( & self , fut : BoxFuture < ' static , ( ) > ) -> Result < ( ) , SpawnError > {
38
38
lazy_static ! {
39
39
static ref TOKIO_RUNTIME : tokio:: runtime:: Runtime = {
40
40
tokio:: runtime:: Builder :: new( )
@@ -46,25 +46,21 @@ impl runtime_raw::Runtime for Tokio {
46
46
} ;
47
47
}
48
48
49
- TOKIO_RUNTIME
50
- . executor ( )
51
- . spawn ( Compat :: new ( fut. map ( |_| Ok ( ( ) ) ) ) ) ;
49
+ TOKIO_RUNTIME . executor ( ) . spawn ( fut. unit_error ( ) . compat ( ) ) ;
52
50
Ok ( ( ) )
53
51
}
54
52
55
53
fn connect_tcp_stream (
56
54
& self ,
57
55
addr : & SocketAddr ,
58
- ) -> Pin < Box < dyn Future < Output = io:: Result < Pin < Box < dyn runtime_raw:: TcpStream > > > > + Send > >
59
- {
60
- use futures:: compat:: Compat01As03 ;
56
+ ) -> BoxFuture < ' static , io:: Result < Pin < Box < dyn runtime_raw:: TcpStream > > > > {
61
57
use futures01:: Future ;
62
58
63
59
let tokio_connect = tokio:: net:: TcpStream :: connect ( addr) ;
64
60
let connect = tokio_connect. map ( |tokio_stream| {
65
61
Box :: pin ( TcpStream { tokio_stream } ) as Pin < Box < dyn runtime_raw:: TcpStream > >
66
62
} ) ;
67
- Box :: pin ( Compat01As03 :: new ( connect) )
63
+ connect. compat ( ) . boxed ( )
68
64
}
69
65
70
66
fn bind_tcp_listener (
@@ -89,7 +85,7 @@ impl runtime_raw::Runtime for Tokio {
89
85
pub struct TokioCurrentThread ;
90
86
91
87
impl runtime_raw:: Runtime for TokioCurrentThread {
92
- fn spawn_obj ( & self , fut : FutureObj < ' static , ( ) > ) -> Result < ( ) , SpawnError > {
88
+ fn spawn_boxed ( & self , fut : BoxFuture < ' static , ( ) > ) -> Result < ( ) , SpawnError > {
93
89
lazy_static ! {
94
90
static ref TOKIO_RUNTIME : Mutex <tokio:: runtime:: current_thread:: Handle > = {
95
91
let ( tx, rx) = mpsc:: channel( ) ;
@@ -114,24 +110,22 @@ impl runtime_raw::Runtime for TokioCurrentThread {
114
110
TOKIO_RUNTIME
115
111
. lock ( )
116
112
. unwrap ( )
117
- . spawn ( Compat :: new ( fut. map ( |_| Ok ( ( ) ) ) ) )
113
+ . spawn ( fut. unit_error ( ) . compat ( ) )
118
114
. unwrap ( ) ;
119
115
Ok ( ( ) )
120
116
}
121
117
122
118
fn connect_tcp_stream (
123
119
& self ,
124
120
addr : & SocketAddr ,
125
- ) -> Pin < Box < dyn Future < Output = io:: Result < Pin < Box < dyn runtime_raw:: TcpStream > > > > + Send > >
126
- {
127
- use futures:: compat:: Compat01As03 ;
121
+ ) -> BoxFuture < ' static , io:: Result < Pin < Box < dyn runtime_raw:: TcpStream > > > > {
128
122
use futures01:: Future ;
129
123
130
124
let tokio_connect = tokio:: net:: TcpStream :: connect ( addr) ;
131
125
let connect = tokio_connect. map ( |tokio_stream| {
132
126
Box :: pin ( TcpStream { tokio_stream } ) as Pin < Box < dyn runtime_raw:: TcpStream > >
133
127
} ) ;
134
- Box :: pin ( Compat01As03 :: new ( connect) )
128
+ connect. compat ( ) . boxed ( )
135
129
}
136
130
137
131
fn bind_tcp_listener (
0 commit comments