mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 09:54:49 +00:00
docs: clarify asyncCheck vs waitFor
This commit is contained in:
committed by
Dominik Picheta
parent
f8cef575b3
commit
4362ba7293
@@ -145,7 +145,9 @@ export asyncfutures, asyncstreams
|
||||
##
|
||||
## Futures should **never** be discarded. This is because they may contain
|
||||
## errors. If you do not care for the result of a Future then you should
|
||||
## use the ``asyncCheck`` procedure instead of the ``discard`` keyword.
|
||||
## use the ``asyncCheck`` procedure instead of the ``discard`` keyword. Note
|
||||
## however that this does not wait for completion, and you should use
|
||||
## ``waitFor`` for that purpose.
|
||||
##
|
||||
## Examples
|
||||
## --------
|
||||
|
||||
@@ -339,7 +339,8 @@ proc asyncCheck*[T](future: Future[T]) =
|
||||
## Sets a callback on ``future`` which raises an exception if the future
|
||||
## finished with an error.
|
||||
##
|
||||
## This should be used instead of ``discard`` to discard void futures.
|
||||
## This should be used instead of ``discard`` to discard void futures,
|
||||
## or use ``waitFor`` if you need to wait for the future's completion.
|
||||
assert(not future.isNil, "Future is nil")
|
||||
future.callback =
|
||||
proc () =
|
||||
|
||||
Reference in New Issue
Block a user