Open
Description
I have serveral concerns about async usage:
- I saw some where on the internet that if we want to check future is failed then we should use yield instead of await to execute the async procedure. Would you put some words in the asyn execute section?
- The {.multisync.} pragma, a simple example should be good for this pragma
- About the {.async.}, Future[T] on the signature of procedure, I find it's quite confusing sometimes, the example in the book as below:
proc tick(t: string): Future[void] {.async.} =
The async pragma can be removed without any problem. So my current understanding is: await keyword can only be used inside a proc which has async pragma, and we can use yield to replace await if we want to check the future status, and we use await/waitFor/asyncCheck on any procedure with return type Future[T].
I finally found the description in the standard library is more accurate and helpful: https://nim-lang.org/docs/asyncdispatch.html
the only thing I don't quite understand is the description in the discard future
:
Note however that this does not wait for completion, and you should use waitFor for that purpose.
I don't know for what purpose I should use waitFor
Metadata
Metadata
Assignees
Labels
No labels