nim-codex/codex/utils/asyncspawn.nim

15 lines
329 B
Nim

import pkg/chronos
proc asyncSpawn*(future: Future[void], ignore: type CatchableError) =
proc ignoringError {.async.} =
try:
await future
except ignore:
discard
asyncSpawn ignoringError()
proc asyncSpawn*[T](future: Future[T]): void =
proc task() {.async.} = discard await future
asyncSpawn task()