Macros
macro async*(a): untyped
-
async macro. Enables you to write asynchronous code in a similar manner to synchronous code.
For example: ```
- proc add5(s: Future[int]): Future[int] {.async.} =
- asyncReturn((await s) + 5)
```
Source Edit macro asyncFor*(iterClause: untyped; body: untyped): untyped
-
An asynchronous version of for that works on Inputs. Example: ```
- proc simplePipe(src: Input[int], dst: Output[int]) {.async.} =
- asyncFor item in src:
- echo "piping ", item await dst.send(item)
```
Source Edit macro asyncIterator*(a): untyped
-
An iterator that produces elements asynchronously. Example: ```
- proc intGenerator(): Input[int] {.asyncIterator.} =
- var i = 0;
- while true:
- asyncYield i i += 1
```
Source Edit