Skip to content

Commit 53700b8

Browse files
Matthias247cramertj
authored andcommitted
Remove the usage of LocalPool for block_on.
It should be no longer necessary, since there is no Spawner passed along the poll chain anymore. This makes block_on cheaper, by avoiding the allocation for LocalPool. It should be allocation free after the first usage.
1 parent 06eaeb5 commit 53700b8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

futures-executor/src/local_pool.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,13 @@ lazy_static! {
203203
/// Run a future to completion on the current thread.
204204
///
205205
/// This function will block the caller until the given future has completed.
206-
/// The default spawner for the future is a global `ThreadPool`.
206+
/// The default spawner for the future is a thread-local executor.
207207
///
208208
/// Use a [`LocalPool`](LocalPool) if you need finer-grained control over
209209
/// spawned tasks.
210210
pub fn block_on<F: Future>(f: F) -> F::Output {
211-
let mut pool = LocalPool::new();
212-
pool.run_until(f)
211+
pin_mut!(f);
212+
run_executor(|local_waker| f.as_mut().poll(local_waker))
213213
}
214214

215215
/// Turn a stream into a blocking iterator.

0 commit comments

Comments
 (0)