mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-21 00:00:10 +02:00
Fix bug with CurrentThread::turn (#152)
CurrentThread::turn uses a turn count strategy to allow `turn` to not run infinitely. Currently, there is a bug where spawned tasks will not get executed in calls to `turn`. This patch fixes the bug by correctly setting the turn count for newly spawned tasks.
This commit is contained in:
@@ -466,6 +466,11 @@ impl<'a, P: Park> Entered<'a, P> {
|
||||
pub fn turn(&mut self, duration: Option<Duration>)
|
||||
-> Result<Turn, TurnError>
|
||||
{
|
||||
if self.executor.is_idle() {
|
||||
// Nothing to do
|
||||
return Ok(Turn(()));
|
||||
}
|
||||
|
||||
if !self.tick() {
|
||||
let res = match duration {
|
||||
Some(duration) => self.executor.park.park_timeout(duration),
|
||||
|
||||
Reference in New Issue
Block a user