Resolve bugs with deep recursion of asyncdispatch.

Introduce callSoon() implementation.
Patch tests to use waitFor() instead of asyncCheck()
This commit is contained in:
cheatfate
2016-05-18 00:53:53 +03:00
parent f4f7edf00f
commit aba60e54d5
4 changed files with 31 additions and 10 deletions

View File

@@ -36,4 +36,4 @@ proc main {.async.} =
discard await g()
echo 6
asyncCheck main()
waitFor(main())

View File

@@ -48,7 +48,7 @@ proc catch() {.async.} =
except OSError, EInvalidField:
assert false
asyncCheck catch()
waitFor catch()
proc test(): Future[bool] {.async.} =
result = false
@@ -92,13 +92,13 @@ proc test4(): Future[int] {.async.} =
result = 2
var x = test()
assert x.read
assert x.waitFor()
x = test2()
assert x.read
assert x.waitFor()
var y = test3()
assert y.read == 2
assert y.waitFor() == 2
y = test4()
assert y.read == 2
assert y.waitFor() == 2

View File

@@ -16,4 +16,4 @@ x.callback =
proc () =
finished = true
while not finished: discard
while not finished: poll()