Don't skip poll() when no handles are present. (#8727)

Fixes #7886.

Fixes #7758.

Fixes #6929.

Fixes #3909.

Replaces #8209.
This commit is contained in:
Dominik Picheta 2018-08-23 15:31:28 +01:00 • committed by Andreas Rumpf
commit 1b1633991a
2 changed files with 84 additions and 69 deletions

View file

@ -299,7 +299,6 @@ when defined(windows) or defined(nimdoc):
"No handles or timers registered in dispatcher.") "No handles or timers registered in dispatcher.")
result = false result = false
if p.handles.len != 0:
let at = p.adjustedTimeout(timeout) let at = p.adjustedTimeout(timeout)
var llTimeout = var llTimeout =
if at == -1: winlean.INFINITE if at == -1: winlean.INFINITE
@ -1231,7 +1230,6 @@ else:
"No handles or timers registered in dispatcher.") "No handles or timers registered in dispatcher.")
result = false result = false
if not p.selector.isEmpty():
var keys: array[64, ReadyKey] var keys: array[64, ReadyKey]
var count = p.selector.selectInto(p.adjustedTimeout(timeout), keys) var count = p.selector.selectInto(p.adjustedTimeout(timeout), keys)
for i in 0..<count: for i in 0..<count:

17
tests/async/t7758.nim Normal file
View file

@ -0,0 +1,17 @@
discard """
file: "t7758.nim"
exitcode: 0
"""
import asyncdispatch
proc task() {.async.} =
await sleepAsync(1000)
when isMainModule:
var counter = 0
var f = task()
while not f.finished:
inc(counter)
poll()
doAssert counter == 2