tlet_spawn.nim 401 B

1234567891011121314151617181920212223242526272829
  1. discard """
  2. output: '''
  3. done999 999
  4. '''
  5. """
  6. import std/[threadpool, os]
  7. proc foo(): int = 999
  8. # test that the disjoint checker deals with 'a = spawn f(); g = spawn f()':
  9. proc main =
  10. parallel:
  11. let f = spawn foo()
  12. let b = spawn foo()
  13. echo "done", f, " ", b
  14. main()
  15. # bug #13781
  16. proc thread(): string =
  17. os.sleep(1000)
  18. return "ok"
  19. var fv = spawn thread()
  20. sync()
  21. doAssert ^fv == "ok"