Module asyncmacro

Types

AsyncIterator* = object
  callback*: proc (cont: proc ())
  Source Edit

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

Templates

template stopAsync*(): typed
  Source Edit
template awaitInIterator*(body: typed; errorFunc: untyped; defers: typed): untyped
  Source Edit
template tryAwait*(body: typed): untyped
Waits for future completion and returns the result.   Source Edit
template asyncMain*(body: untyped): untyped
  Source Edit