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:
Carl Lerche
2018-02-23 22:15:46 -08:00
committed by GitHub
parent fe14e7b127
commit 5334de5e44
3 changed files with 45 additions and 1 deletions
+5
View File
@@ -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),