diff --git a/nim/main.nim b/nim/main.nim new file mode 100644 index 0000000..1a9ceb8 --- /dev/null +++ b/nim/main.nim @@ -0,0 +1,23 @@ +import std/[cmdline, strutils] +import asyncdispatch + +proc asyncTask() {.async.} = + await sleepAsync(10) + +proc main() {.async.} = + var + numTasks: int = 100_000 + futures: seq[Future[void]] = @[] + + when declared(commandLineParams): + if paramCount() > 0: + numTasks = parseInt(commandLineParams()[0]) + + for n in 1..numTasks: + futures.add(asyncTask()) + + for future in futures: + await future + +when isMainModule: + asyncCheck(main())