File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,10 +9,13 @@ use std::{
99} ;
1010
1111thread_local ! {
12- // A local reusable signal for each thread.
13- static LOCAL_THREAD_SIGNAL : Arc <Signal > = Arc :: new( Signal {
14- owning_thread: thread:: current( ) ,
15- } ) ;
12+ // A local reusable waker for each thread.
13+ static LOCAL_WAKER : Waker = {
14+ let signal = Arc :: new( Signal {
15+ owning_thread: thread:: current( ) ,
16+ } ) ;
17+ Waker :: from( signal)
18+ } ;
1619}
1720
1821#[ cfg( feature = "macro" ) ]
@@ -68,10 +71,9 @@ pub fn block_on<F: IntoFuture>(fut: F) -> F::Output {
6871 let mut fut = core:: pin:: pin!( fut. into_future( ) ) ;
6972
7073 // A signal used to wake up the thread for polling as the future moves to completion.
71- LOCAL_THREAD_SIGNAL . with ( |signal| {
72- // Create a waker and a context to be passed to the future.
73- let waker = Waker :: from ( Arc :: clone ( signal) ) ;
74- let mut context = Context :: from_waker ( & waker) ;
74+ LOCAL_WAKER . with ( |waker| {
75+ // Create a context to be passed to the future.
76+ let mut context = Context :: from_waker ( waker) ;
7577
7678 // Poll the future to completion.
7779 loop {
You can’t perform that action at this time.
0 commit comments