mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-01 13:09:14 +00:00
26 lines
362 B
Nim
26 lines
362 B
Nim
discard """
|
|
output: '''
|
|
iteration: 1
|
|
iteration: 2
|
|
iteration: 3
|
|
iteration: 4
|
|
async done
|
|
iteration: 5
|
|
'''
|
|
"""
|
|
|
|
import asyncdispatch, times
|
|
|
|
var done = false
|
|
proc somethingAsync() {.async.} =
|
|
yield sleepAsync 1000
|
|
echo "async done"
|
|
done = true
|
|
|
|
asyncCheck somethingAsync()
|
|
var count = 0
|
|
while not done:
|
|
count += 1
|
|
drain 200
|
|
echo "iteration: ", count
|