File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -194,7 +194,18 @@ impl TaskPool {
194194 let fut: Pin < & ' static mut ( dyn Future < Output = Vec < T > > + Send + ' static ) > =
195195 unsafe { mem:: transmute ( fut) } ;
196196
197- future:: block_on ( self . executor . spawn ( fut) )
197+ // The thread that calls scope() will participate in driving tasks in the pool forward
198+ // until the tasks that are spawned by this scope() call complete. (If the caller of scope()
199+ // happens to be a thread in this thread pool, and we only have one thread in the pool, then
200+ // simply calling future::block_on(spawned) would deadlock.)
201+ let mut spawned = self . executor . spawn ( fut) ;
202+ loop {
203+ if let Some ( result) = future:: block_on ( future:: poll_once ( & mut spawned) ) {
204+ break result;
205+ }
206+
207+ self . executor . try_tick ( ) ;
208+ }
198209 }
199210
200211 /// Spawns a static future onto the thread pool. The returned Task is a future. It can also be
You can’t perform that action at this time.
0 commit comments