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