@@ -15,11 +15,11 @@ use futures_core::{Stream, Future, Poll};
15
15
use futures_core:: task:: { self , AtomicWaker } ;
16
16
17
17
mod abort;
18
- mod inner ;
18
+ mod ready_to_run_queue ;
19
19
mod iter_mut;
20
20
mod node;
21
21
22
- use self :: inner :: { Inner , Dequeue } ;
22
+ use self :: ready_to_run_queue :: { ReadyToRunQueue , Dequeue } ;
23
23
use self :: iter_mut:: IterMut ;
24
24
use self :: node:: Node ;
25
25
@@ -40,7 +40,7 @@ use self::node::Node;
40
40
/// an empty set with the `FuturesUnordered::new` constructor.
41
41
#[ must_use = "streams do nothing unless polled" ]
42
42
pub struct FuturesUnordered < F > {
43
- inner : Arc < Inner < F > > ,
43
+ ready_to_run_queue : Arc < ReadyToRunQueue < F > > ,
44
44
len : usize ,
45
45
head_all : * const Node < F > ,
46
46
}
@@ -85,22 +85,22 @@ impl<T> FuturesUnordered<T>
85
85
future : UnsafeCell :: new ( None ) ,
86
86
next_all : UnsafeCell :: new ( ptr:: null ( ) ) ,
87
87
prev_all : UnsafeCell :: new ( ptr:: null ( ) ) ,
88
- next_readiness : AtomicPtr :: new ( ptr:: null_mut ( ) ) ,
88
+ next_ready_to_run : AtomicPtr :: new ( ptr:: null_mut ( ) ) ,
89
89
queued : AtomicBool :: new ( true ) ,
90
- queue : Weak :: new ( ) ,
90
+ ready_to_run_queue : Weak :: new ( ) ,
91
91
} ) ;
92
92
let stub_ptr = & * stub as * const Node < T > ;
93
- let inner = Arc :: new ( Inner {
93
+ let ready_to_run_queue = Arc :: new ( ReadyToRunQueue {
94
94
parent : AtomicWaker :: new ( ) ,
95
- head_readiness : AtomicPtr :: new ( stub_ptr as * mut _ ) ,
96
- tail_readiness : UnsafeCell :: new ( stub_ptr) ,
95
+ head : AtomicPtr :: new ( stub_ptr as * mut _ ) ,
96
+ tail : UnsafeCell :: new ( stub_ptr) ,
97
97
stub : stub,
98
98
} ) ;
99
99
100
100
FuturesUnordered {
101
101
len : 0 ,
102
102
head_all : ptr:: null_mut ( ) ,
103
- inner : inner ,
103
+ ready_to_run_queue : ready_to_run_queue ,
104
104
}
105
105
}
106
106
}
@@ -129,9 +129,9 @@ impl<T> FuturesUnordered<T> {
129
129
future : UnsafeCell :: new ( Some ( future) ) ,
130
130
next_all : UnsafeCell :: new ( ptr:: null_mut ( ) ) ,
131
131
prev_all : UnsafeCell :: new ( ptr:: null_mut ( ) ) ,
132
- next_readiness : AtomicPtr :: new ( ptr:: null_mut ( ) ) ,
132
+ next_ready_to_run : AtomicPtr :: new ( ptr:: null_mut ( ) ) ,
133
133
queued : AtomicBool :: new ( true ) ,
134
- queue : Arc :: downgrade ( & self . inner ) ,
134
+ ready_to_run_queue : Arc :: downgrade ( & self . ready_to_run_queue ) ,
135
135
} ) ;
136
136
137
137
// Right now our node has a strong reference count of 1. We transfer
@@ -143,7 +143,7 @@ impl<T> FuturesUnordered<T> {
143
143
// e.g. getting its unpark notifications going to us tracking which
144
144
// futures are ready. To do that we unconditionally enqueue it for
145
145
// polling here.
146
- self . inner . enqueue ( ptr) ;
146
+ self . ready_to_run_queue . enqueue ( ptr) ;
147
147
}
148
148
149
149
/// Returns an iterator that allows modifying each future in the set.
@@ -232,12 +232,12 @@ impl<T> Stream for FuturesUnordered<T>
232
232
-> Poll < Option < Self :: Item > >
233
233
{
234
234
// Ensure `parent` is correctly set.
235
- self . inner . parent . register ( cx. waker ( ) ) ;
235
+ self . ready_to_run_queue . parent . register ( cx. waker ( ) ) ;
236
236
237
237
loop {
238
238
// Safety: &mut self guarantees the mutual exclusion `dequeue`
239
239
// expects
240
- let node = match unsafe { self . inner . dequeue ( ) } {
240
+ let node = match unsafe { self . ready_to_run_queue . dequeue ( ) } {
241
241
Dequeue :: Empty => {
242
242
if self . is_empty ( ) {
243
243
return Poll :: Ready ( None ) ;
@@ -255,7 +255,7 @@ impl<T> Stream for FuturesUnordered<T>
255
255
Dequeue :: Data ( node) => node,
256
256
} ;
257
257
258
- debug_assert ! ( node != self . inner . stub( ) ) ;
258
+ debug_assert ! ( node != self . ready_to_run_queue . stub( ) ) ;
259
259
260
260
// Safety:
261
261
// - Node is a valid pointer.
@@ -376,7 +376,7 @@ impl<T> Drop for FuturesUnordered<T> {
376
376
// mpsc queue. None of those nodes, however, have futures associated
377
377
// with them so they're safe to destroy on any thread. At this point
378
378
// the `FuturesUnordered` struct, the owner of the one strong reference
379
- // to `Inner <T>` will drop the strong reference. At that point
379
+ // to `MPSCQueue <T>` will drop the strong reference. At that point
380
380
// whichever thread releases the strong refcount last (be it this
381
381
// thread or some other thread as part of an `upgrade`) will clear out
382
382
// the mpsc queue and free all remaining nodes.
0 commit comments