t14820.nim 363 B

1234567891011121314151617181920212223242526
  1. discard """
  2. output: '''
  3. iteration: 1
  4. iteration: 2
  5. iteration: 3
  6. iteration: 4
  7. async done
  8. iteration: 5
  9. '''
  10. """
  11. import asyncdispatch, times
  12. var done = false
  13. proc somethingAsync() {.async.} =
  14. yield sleepAsync 5000
  15. echo "async done"
  16. done = true
  17. asyncCheck somethingAsync()
  18. var count = 0
  19. while not done:
  20. count += 1
  21. drain 1000
  22. echo "iteration: ", count