Skip to content

Commit c02ec75

Browse files
Merge pull request #1198 from Nemo157/new-nightly
Update for new nightly
2 parents dc159c9 + 8124b82 commit c02ec75

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+259
-280
lines changed

futures-channel/benches/sync_mpsc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ fn notify_noop() -> LocalWaker {
2222

2323
fn noop_cx(f: impl FnOnce(&mut task::Context)) {
2424
let pool = LocalPool::new();
25-
let mut exec = pool.executor();
25+
let mut spawn = pool.spawner();
2626
let waker = notify_noop();
27-
let cx = &mut task::Context::new(&waker, &mut exec);
27+
let cx = &mut task::Context::new(&waker, &mut spawn);
2828
f(cx)
2929
}
3030

futures-core/src/task.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Task notification.
22
33
pub use core::task::{
4-
Context, Poll, Executor,
4+
Context, Poll, Spawn,
55
Waker, LocalWaker, UnsafeWake,
66
SpawnErrorKind, SpawnObjError, SpawnLocalObjError,
77
};

futures-executor/benches/poll.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ fn task_init(b: &mut Bencher) {
5757
};
5858

5959
let pool = LocalPool::new();
60-
let mut exec = pool.executor();
60+
let mut spawn = pool.spawner();
6161
let waker = notify_noop();
62-
let mut cx = task::Context::new(&waker, &mut exec);
62+
let mut cx = task::Context::new(&waker, &mut spawn);
6363

6464
b.iter(|| {
6565
fut.num = 0;

futures-executor/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ macro_rules! if_std {
1818

1919
if_std! {
2020
mod local_pool;
21-
pub use crate::local_pool::{block_on, block_on_stream, BlockingStream, LocalPool, LocalExecutor};
21+
pub use crate::local_pool::{block_on, block_on_stream, BlockingStream, LocalPool, LocalSpawn};
2222

2323
mod unpark_mutex;
2424
mod thread_pool;

futures-executor/src/local_pool.rs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use futures_core::future::{Future, FutureObj, LocalFutureObj};
33
use futures_core::stream::{Stream};
44
use futures_core::task::{
55
self, Context, Poll, LocalWaker, Wake,
6-
Executor, SpawnObjError, SpawnLocalObjError, SpawnErrorKind
6+
Spawn, SpawnObjError, SpawnLocalObjError, SpawnErrorKind
77
};
88
use futures_util::stream::FuturesUnordered;
99
use futures_util::stream::StreamExt;
@@ -24,20 +24,20 @@ use std::thread::{self, Thread};
2424
/// little work in between I/O actions.
2525
///
2626
/// To get a handle to the pool that implements
27-
/// [`Executor`](futures_core::task::Executor), use the
28-
/// [`executor()`](LocalPool::executor) method. Because the executor is
27+
/// [`Spawn`](futures_core::task::Spawn), use the
28+
/// [`spawner()`](LocalPool::spawner) method. Because the executor is
2929
/// single-threaded, it supports a special form of task spawning for non-`Send`
30-
/// futures, via [`spawn_local_obj`](LocalExecutor::spawn_local_obj).
30+
/// futures, via [`spawn_local_obj`](LocalSpawn::spawn_local_obj).
3131
#[derive(Debug)]
3232
pub struct LocalPool {
3333
pool: FuturesUnordered<LocalFutureObj<'static, ()>>,
3434
incoming: Rc<Incoming>,
3535
}
3636

3737
/// A handle to a [`LocalPool`](LocalPool) that implements
38-
/// [`Executor`](futures_core::task::Executor).
38+
/// [`Spawn`](futures_core::task::Spawn).
3939
#[derive(Clone, Debug)]
40-
pub struct LocalExecutor {
40+
pub struct LocalSpawn {
4141
incoming: Weak<Incoming>,
4242
}
4343

@@ -59,7 +59,7 @@ impl Wake for ThreadNotify {
5959
}
6060
}
6161

62-
// Set up and run a basic single-threaded executor loop, invocing `f` on each
62+
// Set up and run a basic single-threaded spawner loop, invoking `f` on each
6363
// turn.
6464
fn run_executor<T, F: FnMut(&LocalWaker) -> Poll<T>>(mut f: F) -> T {
6565
let _enter = enter()
@@ -87,71 +87,71 @@ impl LocalPool {
8787
}
8888
}
8989

90-
/// Get a clonable handle to the pool as an executor.
91-
pub fn executor(&self) -> LocalExecutor {
92-
LocalExecutor {
90+
/// Get a clonable handle to the pool as a [`Spawn`].
91+
pub fn spawner(&self) -> LocalSpawn {
92+
LocalSpawn {
9393
incoming: Rc::downgrade(&self.incoming)
9494
}
9595
}
9696

9797
/// Run all tasks in the pool to completion.
9898
///
99-
/// The given executor, `exec`, is used as the default executor for any
99+
/// The given spawner, `spawn`, is used as the default spawner for any
100100
/// *newly*-spawned tasks. You can route these additional tasks back into
101-
/// the `LocalPool` by using its executor handle:
101+
/// the `LocalPool` by using its spawner handle:
102102
///
103103
/// ```
104104
/// use futures::executor::LocalPool;
105105
///
106106
/// let mut pool = LocalPool::new();
107-
/// let mut exec = pool.executor();
107+
/// let mut spawn = pool.spawner();
108108
///
109-
/// // ... spawn some initial tasks using `exec.spawn()` or `exec.spawn_local()`
109+
/// // ... spawn some initial tasks using `spawn.spawn()` or `spawn.spawn_local()`
110110
///
111111
/// // run *all* tasks in the pool to completion, including any newly-spawned ones.
112-
/// pool.run(&mut exec);
112+
/// pool.run(&mut spawn);
113113
/// ```
114114
///
115115
/// The function will block the calling thread until *all* tasks in the pool
116116
/// are complete, including any spawned while running existing tasks.
117-
pub fn run<Exec>(&mut self, exec: &mut Exec) where Exec: Executor + Sized {
118-
run_executor(|local_waker| self.poll_pool(local_waker, exec))
117+
pub fn run<Sp>(&mut self, spawn: &mut Sp) where Sp: Spawn + Sized {
118+
run_executor(|local_waker| self.poll_pool(local_waker, spawn))
119119
}
120120

121121
/// Runs all the tasks in the pool until the given future completes.
122122
///
123-
/// The given executor, `exec`, is used as the default executor for any
123+
/// The given spawner, `spawn`, is used as the default spawner for any
124124
/// *newly*-spawned tasks. You can route these additional tasks back into
125-
/// the `LocalPool` by using its executor handle:
125+
/// the `LocalPool` by using its spawner handle:
126126
///
127127
/// ```
128128
/// #![feature(pin, arbitrary_self_types, futures_api)]
129129
/// use futures::executor::LocalPool;
130130
/// use futures::future::ready;
131131
///
132132
/// let mut pool = LocalPool::new();
133-
/// let mut exec = pool.executor();
133+
/// let mut spawn = pool.spawner();
134134
/// # let my_app = ready(());
135135
///
136136
/// // run tasks in the pool until `my_app` completes, by default spawning
137137
/// // further tasks back onto the pool
138-
/// pool.run_until(my_app, &mut exec);
138+
/// pool.run_until(my_app, &mut spawn);
139139
/// ```
140140
///
141141
/// The function will block the calling thread *only* until the future `f`
142142
/// completes; there may still be incomplete tasks in the pool, which will
143143
/// be inert after the call completes, but can continue with further use of
144144
/// `run` or `run_until`. While the function is running, however, all tasks
145145
/// in the pool will try to make progress.
146-
pub fn run_until<F, Exec>(&mut self, future: F, exec: &mut Exec)
146+
pub fn run_until<F, Sp>(&mut self, future: F, spawn: &mut Sp)
147147
-> F::Output
148-
where F: Future, Exec: Executor + Sized
148+
where F: Future, Sp: Spawn + Sized
149149
{
150150
pin_mut!(future);
151151

152152
run_executor(|local_waker| {
153153
{
154-
let mut main_cx = Context::new(local_waker, exec);
154+
let mut main_cx = Context::new(local_waker, spawn);
155155

156156
// if our main task is done, so are we
157157
let result = future.reborrow().poll(&mut main_cx);
@@ -160,19 +160,19 @@ impl LocalPool {
160160
}
161161
}
162162

163-
self.poll_pool(local_waker, exec);
163+
self.poll_pool(local_waker, spawn);
164164
Poll::Pending
165165
})
166166
}
167167

168168
// Make maximal progress on the entire pool of spawned task, returning `Ready`
169169
// if the pool is empty and `Pending` if no further progress can be made.
170-
fn poll_pool<Exec>(&mut self, local_waker: &LocalWaker, exec: &mut Exec)
170+
fn poll_pool<Sp>(&mut self, local_waker: &LocalWaker, spawn: &mut Sp)
171171
-> Poll<()>
172-
where Exec: Executor + Sized
172+
where Sp: Spawn + Sized
173173
{
174174
// state for the FuturesUnordered, which will never be used
175-
let mut pool_cx = Context::new(local_waker, exec);
175+
let mut pool_cx = Context::new(local_waker, spawn);
176176

177177
loop {
178178
// empty the incoming queue of newly-spawned tasks
@@ -215,7 +215,7 @@ lazy_static! {
215215
/// Run a future to completion on the current thread.
216216
///
217217
/// This function will block the caller until the given future has completed.
218-
/// The default executor for the future is a global `ThreadPool`.
218+
/// The default spawner for the future is a global `ThreadPool`.
219219
///
220220
/// Use a [`LocalPool`](LocalPool) if you need finer-grained control over
221221
/// spawned tasks.
@@ -228,7 +228,7 @@ pub fn block_on<F: Future>(f: F) -> F::Output {
228228
///
229229
/// When `next` is called on the resulting `BlockingStream`, the caller
230230
/// will be blocked until the next element of the `Stream` becomes available.
231-
/// The default executor for the future is a global `ThreadPool`.
231+
/// The default spawner for the future is a global `ThreadPool`.
232232
pub fn block_on_stream<S: Stream + Unpin>(stream: S) -> BlockingStream<S> {
233233
BlockingStream { stream }
234234
}
@@ -264,7 +264,7 @@ impl<S: Stream + Unpin> Iterator for BlockingStream<S> {
264264
}
265265
}
266266

267-
impl Executor for LocalExecutor {
267+
impl Spawn for LocalSpawn {
268268
fn spawn_obj(
269269
&mut self,
270270
future: FutureObj<'static, ()>,
@@ -286,7 +286,7 @@ impl Executor for LocalExecutor {
286286
}
287287
}
288288

289-
impl LocalExecutor {
289+
impl LocalSpawn {
290290
/// Spawn a non-`Send` future onto the associated [`LocalPool`](LocalPool).
291291
pub fn spawn_local_obj(
292292
&mut self,

futures-executor/src/thread_pool.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::enter;
22
use crate::unpark_mutex::UnparkMutex;
33
use futures_core::future::{Future, FutureObj};
4-
use futures_core::task::{self, Poll, Wake, Executor, SpawnObjError};
4+
use futures_core::task::{self, Poll, Wake, Spawn, SpawnObjError};
55
use futures_util::future::FutureExt;
66
use futures_util::task::local_waker_ref_from_nonlocal;
77
use num_cpus;
@@ -85,12 +85,12 @@ impl ThreadPool {
8585
ThreadPoolBuilder::new()
8686
}
8787

88-
/// Runs the given future with this thread pool as the default executor for
88+
/// Runs the given future with this thread pool as the default spawner for
8989
/// spawning tasks.
9090
///
9191
/// **This function will block the calling thread** until the given future
9292
/// is complete. While executing that future, any tasks spawned onto the
93-
/// default executor will be routed to this thread pool.
93+
/// default spawner will be routed to this thread pool.
9494
///
9595
/// Note that the function will return when the provided future completes,
9696
/// even if some of the tasks it spawned are still running.
@@ -99,7 +99,7 @@ impl ThreadPool {
9999
}
100100
}
101101

102-
impl Executor for ThreadPool {
102+
impl Spawn for ThreadPool {
103103
fn spawn_obj(
104104
&mut self,
105105
future: FutureObj<'static, ()>,

0 commit comments

Comments
 (0)