twait.nim 508 B

1234567891011121314151617181920212223242526272829
  1. discard """
  2. output: "Exit 1\nExit 2"
  3. matrix: "--gc:refc; --gc:arc; --gc:orc"
  4. target: "c"
  5. """
  6. when compileOption("gc", "refc") or not defined(openbsd):
  7. # xxx openbsd failed, see tgc.nim
  8. import coro
  9. var coro1: CoroutineRef
  10. proc testCoroutine1() =
  11. for i in 0..<10:
  12. suspend(0)
  13. echo "Exit 1"
  14. proc testCoroutine2() =
  15. coro1.wait()
  16. echo "Exit 2"
  17. coro1 = coro.start(testCoroutine1)
  18. coro.start(testCoroutine2)
  19. run()
  20. else:
  21. # workaround
  22. echo "Exit 1"
  23. echo "Exit 2"