@@ -6,15 +6,13 @@ use futures::future::BoxFuture;
6
6
use std:: cell:: RefCell ;
7
7
use std:: future:: Future ;
8
8
use std:: pin:: Pin ;
9
- use std:: sync:: { Arc , Mutex } ;
9
+ use std:: sync:: { mpsc , Arc , Mutex } ;
10
10
use std:: task:: { Context , Poll , Waker } ;
11
11
use std:: thread;
12
12
use std:: time:: { Duration , Instant } ;
13
13
// A utility that allows us to implement a `std::task::Waker` without having to
14
14
// use `unsafe` code.
15
15
use futures:: task:: { self , ArcWake } ;
16
- // Used as a channel to queue scheduled tasks.
17
- use crossbeam:: channel;
18
16
19
17
// Main entry point. A mini-tokio instance is created and a few tasks are
20
18
// spawned. Our mini-tokio implementation only supports spawning tasks and
@@ -60,16 +58,16 @@ struct MiniTokio {
60
58
// is ready to make progress. This usually happens when a resource the task
61
59
// uses becomes ready to perform an operation. For example, a socket
62
60
// received data and a `read` call will succeed.
63
- scheduled : channel :: Receiver < Arc < Task > > ,
61
+ scheduled : mpsc :: Receiver < Arc < Task > > ,
64
62
65
63
// Send half of the scheduled channel.
66
- sender : channel :: Sender < Arc < Task > > ,
64
+ sender : mpsc :: Sender < Arc < Task > > ,
67
65
}
68
66
69
67
impl MiniTokio {
70
68
/// Initialize a new mini-tokio instance.
71
69
fn new ( ) -> MiniTokio {
72
- let ( sender, scheduled) = channel :: unbounded ( ) ;
70
+ let ( sender, scheduled) = mpsc :: channel ( ) ;
73
71
74
72
MiniTokio { scheduled, sender }
75
73
}
@@ -232,7 +230,7 @@ async fn delay(dur: Duration) {
232
230
// Used to track the current mini-tokio instance so that the `spawn` function is
233
231
// able to schedule spawned tasks.
234
232
thread_local ! {
235
- static CURRENT : RefCell <Option <channel :: Sender <Arc <Task >>>> =
233
+ static CURRENT : RefCell <Option <mpsc :: Sender <Arc <Task >>>> =
236
234
RefCell :: new( None ) ;
237
235
}
238
236
@@ -250,7 +248,7 @@ struct Task {
250
248
251
249
// When a task is notified, it is queued into this channel. The executor
252
250
// pops notified tasks and executes them.
253
- executor : channel :: Sender < Arc < Task > > ,
251
+ executor : mpsc :: Sender < Arc < Task > > ,
254
252
}
255
253
256
254
impl Task {
@@ -259,7 +257,7 @@ impl Task {
259
257
// Initializes a new Task harness containing the given future and pushes it
260
258
// onto `sender`. The receiver half of the channel will get the task and
261
259
// execute it.
262
- fn spawn < F > ( future : F , sender : & channel :: Sender < Arc < Task > > )
260
+ fn spawn < F > ( future : F , sender : & mpsc :: Sender < Arc < Task > > )
263
261
where
264
262
F : Future < Output = ( ) > + Send + ' static ,
265
263
{
0 commit comments