Fix wait() to allow Future[void].

This commit is contained in:
cheatfate 2019-03-28 00:56:17 +02:00
parent 51c87bf090
commit 7d63a1b54d
No known key found for this signature in database
GPG Key ID: 46ADD633A7201F95
1 changed files with 8 additions and 2 deletions

View File

@ -768,7 +768,10 @@ proc wait*[T](fut: Future[T], timeout = InfiniteDuration): Future[T] =
if fut.failed:
retFuture.fail(fut.error)
else:
retFuture.complete(fut.read())
when T is void:
retFuture.complete()
else:
retFuture.complete(fut.read())
if timeout.isInfinite():
retFuture = fut
elif timeout.isZero():
@ -776,7 +779,10 @@ proc wait*[T](fut: Future[T], timeout = InfiniteDuration): Future[T] =
if fut.failed:
retFuture.fail(fut.error)
else:
retFuture.complete(fut.read())
when T is void:
retFuture.complete()
else:
retFuture.complete(fut.read())
else:
retFuture.fail(newException(AsyncTimeoutError, ""))
else: