Module asyncutil

Types

CompleterTable*[K, V] = ref object
  completers: Table[K, seq[Completer[V]]]
A dictionary of completers. Useful for implementing RPC protocols with message ids.   Source Edit
SerialQueue* = ref object
  streamBefore: Input[SerialQueueItem]
  providerBefore: Output[SerialQueueItem]
  streamAfter: Input[proc (): Future[void]]
  providerAfter: Output[proc (): Future[void]]
A queue that executes asynchronous functions serially   Source Edit

Procs

proc hash*(x: uint64): Hash
  Source Edit
proc newCompleterTable*[K, V](): CompleterTable[K, V]
Creates a dictionary of completers.   Source Edit
proc waitFor*[K, V](self: CompleterTable[K, V]; id: K): Future[V]
Wait for completion of event with id id. Doesn't return values for already completed events.   Source Edit
proc complete*[K, V](self: CompleterTable[K, V]; id: K; value: V)
Complete all futures requested by waitFor for id id.   Source Edit
proc newSerialQueue*(): SerialQueue
  Source Edit
proc enqueue*[T](q: SerialQueue; before: (proc (): Future[void]);
                after: (proc (): Future[T])): Future[T] {.
async
.}
Executes all before`s and `after`s in the same order. Additionally, if `enqueue A is executed before enqueue B functions from A will be executed before functions from B.   Source Edit
proc forEachChunk*[T](self: Input[T]; function: (proc (x: seq[T]))): Future[void] {.
async
.}
  Source Edit
proc forEach*[T](self: Input[T]; function: (proc (x: T))): Future[void] {.
async
.}
  Source Edit
proc pipeLimited*[T](self: Input[T]; provider: Output[T]; limit: int64; close = true): Future[
    void] {.
async
.}
  Source Edit
proc newConstInput*[T](val: seq[T]): Input[T]
  Source Edit
proc newConstInput*(val: string): Input[byte]
  Source Edit
proc newLengthInput*[T](data: seq[T]): LengthInput[T]
  Source Edit
proc newLengthInput*(data: string): LengthInput[byte]
  Source Edit
proc nullOutput*[T](t: typedesc[T]): Output[T]
  Source Edit
proc zip*[A](a: seq[Future[A]]): Future[seq[A]] {.
async
.}
  Source Edit
proc zipVoid*(a: seq[Future[void]]): Future[void]
  Source Edit
proc any*[T](futures: seq[Future[T]]): Future[T]
Wait until one of the futures finishes successfully. If all of the futures fail, return an error.   Source Edit
proc splitFuture*[A, B](f: Future[tuple[a: A, b: B]]): tuple[a: Future[A], b: Future[B]]
Converts a future of tuple to tuple of futures.   Source Edit
proc unwrapPipeFuture*[T](f: Future[Pipe[T]]): Pipe[T]
  Source Edit
proc pipe*[T](a: Pipe[T]; b: Pipe[T]): Future[void]
  Source Edit
proc asyncPipe*[T](f: proc (s: Input[T]): Future[void]): Output[T]
Create a new pipe, return output side. Call f in background with input as an argument
  • when it errors, close the output.
  Source Edit