t7172.nim 552 B

1234567891011121314151617181920212223242526272829303132333435
  1. discard """
  2. disabled: i386
  3. output: '''
  4. In doStuff()
  5. In initProcess()
  6. TEST
  7. initProcess() done
  8. Crashes before getting here!
  9. '''
  10. joinable: false
  11. """
  12. import std/os
  13. import std/typedthreads
  14. proc whatever() {.thread, nimcall.} =
  15. echo("TEST")
  16. proc initProcess(): void =
  17. echo("In initProcess()")
  18. var thread: Thread[void]
  19. createThread(thread, whatever)
  20. joinThread(thread)
  21. echo("initProcess() done")
  22. proc doStuff(): void =
  23. echo("In doStuff()")
  24. # ...
  25. initProcess()
  26. sleep(500)
  27. # ...
  28. echo("Crashes before getting here!")
  29. doStuff()