1
1
use crate :: { Instrument , Instrumented , WithDispatch } ;
2
+ #[ cfg( feature = "futures-01" ) ]
2
3
use futures:: {
3
- future:: { ExecuteError , Executor } ,
4
- Future ,
5
- } ;
6
-
7
- #[ cfg( feature = "tokio" ) ]
8
- use tokio:: {
9
- executor:: { Executor as TokioExecutor , SpawnError } ,
10
- runtime:: { current_thread, Runtime , TaskExecutor } ,
4
+ future:: { ExecuteError , Executor } ,
5
+ Future ,
11
6
} ;
7
+ #[ cfg( feature = "futures-01" ) ]
8
+ use tokio:: executor:: { Executor as TokioExecutor , SpawnError } ;
9
+ use tokio:: runtime:: { current_thread, Runtime , TaskExecutor } ;
12
10
11
+ #[ cfg( feature = "futures-01" ) ]
13
12
macro_rules! deinstrument_err {
14
13
( $e: expr) => {
15
14
$e. map_err( |e| {
@@ -20,6 +19,7 @@ macro_rules! deinstrument_err {
20
19
} ;
21
20
}
22
21
22
+ #[ cfg( feature = "futures-01" ) ]
23
23
impl < T , F > Executor < F > for Instrumented < T >
24
24
where
25
25
T : Executor < Instrumented < F > > ,
31
31
}
32
32
}
33
33
34
- #[ cfg( feature = "tokio" ) ]
34
+ #[ cfg( all ( feature = "futures-01" , feature = " tokio") ) ]
35
35
impl < T > TokioExecutor for Instrumented < T >
36
36
where
37
37
T : TokioExecutor ,
@@ -56,6 +56,7 @@ impl Instrumented<Runtime> {
56
56
///
57
57
/// This method simply wraps a call to `tokio::runtime::Runtime::spawn`,
58
58
/// instrumenting the spawned future beforehand.
59
+ #[ cfg( feature = "futures-01" ) ]
59
60
pub fn spawn < F > ( & mut self , future : F ) -> & mut Self
60
61
where
61
62
F : Future < Item = ( ) , Error = ( ) > + Send + ' static ,
@@ -80,6 +81,7 @@ impl Instrumented<Runtime> {
80
81
///
81
82
/// This function panics if the executor is at capacity, if the provided
82
83
/// future panics, or if called within an asynchronous execution context.
84
+ #[ cfg( feature = "futures-01" ) ]
83
85
pub fn block_on < F , R , E > ( & mut self , future : F ) -> Result < R , E >
84
86
where
85
87
F : Send + ' static + Future < Item = R , Error = E > ,
@@ -108,6 +110,7 @@ impl Instrumented<current_thread::Runtime> {
108
110
///
109
111
/// This method simply wraps a call to `current_thread::Runtime::spawn`,
110
112
/// instrumenting the spawned future beforehand.
113
+ #[ cfg( feature = "futures-01" ) ]
111
114
pub fn spawn < F > ( & mut self , future : F ) -> & mut Self
112
115
where
113
116
F : Future < Item = ( ) , Error = ( ) > + ' static ,
@@ -141,6 +144,7 @@ impl Instrumented<current_thread::Runtime> {
141
144
///
142
145
/// This function panics if the executor is at capacity, if the provided
143
146
/// future panics, or if called within an asynchronous execution context.
147
+ #[ cfg( feature = "futures-01" ) ]
144
148
pub fn block_on < F , R , E > ( & mut self , future : F ) -> Result < R , E >
145
149
where
146
150
F : ' static + Future < Item = R , Error = E > ,
@@ -165,6 +169,7 @@ impl Instrumented<current_thread::Runtime> {
165
169
}
166
170
}
167
171
172
+ #[ cfg( feature = "futures-01" ) ]
168
173
impl < T , F > Executor < F > for WithDispatch < T >
169
174
where
170
175
T : Executor < WithDispatch < F > > ,
@@ -176,7 +181,7 @@ where
176
181
}
177
182
}
178
183
179
- #[ cfg( feature = "tokio" ) ]
184
+ #[ cfg( all ( feature = "futures-01" , feature = " tokio") ) ]
180
185
impl < T > TokioExecutor for WithDispatch < T >
181
186
where
182
187
T : TokioExecutor ,
@@ -202,6 +207,7 @@ impl WithDispatch<Runtime> {
202
207
///
203
208
/// This method simply wraps a call to `tokio::runtime::Runtime::spawn`,
204
209
/// instrumenting the spawned future beforehand.
210
+ #[ cfg( feature = "futures-01" ) ]
205
211
pub fn spawn < F > ( & mut self , future : F ) -> & mut Self
206
212
where
207
213
F : Future < Item = ( ) , Error = ( ) > + Send + ' static ,
@@ -227,6 +233,7 @@ impl WithDispatch<Runtime> {
227
233
///
228
234
/// This function panics if the executor is at capacity, if the provided
229
235
/// future panics, or if called within an asynchronous execution context.
236
+ #[ cfg( feature = "futures-01" ) ]
230
237
pub fn block_on < F , R , E > ( & mut self , future : F ) -> Result < R , E >
231
238
where
232
239
F : Send + ' static + Future < Item = R , Error = E > ,
@@ -257,6 +264,7 @@ impl WithDispatch<current_thread::Runtime> {
257
264
///
258
265
/// This method simply wraps a call to `current_thread::Runtime::spawn`,
259
266
/// instrumenting the spawned future beforehand.
267
+ #[ cfg( feature = "futures-01" ) ]
260
268
pub fn spawn < F > ( & mut self , future : F ) -> & mut Self
261
269
where
262
270
F : Future < Item = ( ) , Error = ( ) > + ' static ,
@@ -290,6 +298,7 @@ impl WithDispatch<current_thread::Runtime> {
290
298
///
291
299
/// This function panics if the executor is at capacity, if the provided
292
300
/// future panics, or if called within an asynchronous execution context.
301
+ #[ cfg( feature = "futures-01" ) ]
293
302
pub fn block_on < F , R , E > ( & mut self , future : F ) -> Result < R , E >
294
303
where
295
304
F : ' static + Future < Item = R , Error = E > ,
0 commit comments