This commit is contained in:
Eugene Kabanov 2020-04-06 15:49:09 +03:00 committed by GitHub
parent 4e2810cfe0
commit 3d745a4b0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 3 deletions

View File

@ -47,9 +47,7 @@ template createCb(retFutureSym, iteratorNameSym,
raise newException(AssertionError, msg % strName)
else:
{.gcsafe.}:
{.push hint[ConvFromXtoItselfNotNeeded]: off.}
next.callback = identName
{.pop.}
next.addCallback(identName)
except CancelledError:
retFutureSym.cancel()
except CatchableError as exc:

View File

@ -56,6 +56,23 @@ suite "Asynchronous issues test suite":
discard await withTimeout(sleepAsync(4.milliseconds), 4.milliseconds)
result = true
proc testMultipleAwait(): Future[bool] {.async.} =
var promise = newFuture[void]()
var checkstr = ""
proc believers(name: string) {.async.} =
await promise
checkstr = checkstr & name
asyncCheck believers("Foo")
asyncCheck believers("Bar")
asyncCheck believers("Baz")
await sleepAsync(100.milliseconds)
promise.complete()
await sleepAsync(100.milliseconds)
result = (checkstr == "FooBarBaz")
test "Issue #6":
check waitFor(issue6()) == true
@ -64,3 +81,6 @@ suite "Asynchronous issues test suite":
test "Callback-race double completion [withTimeout()] test":
check waitFor(testWithTimeout()) == true
test "Multiple await on single future test [Nim's issue #13889]":
check waitFor(testMultipleAwait()) == true