diff options
Diffstat (limited to 'lib/system/threads.nim')
-rwxr-xr-x | lib/system/threads.nim | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/system/threads.nim b/lib/system/threads.nim index a458dffe9..60643b526 100755 --- a/lib/system/threads.nim +++ b/lib/system/threads.nim @@ -290,6 +290,10 @@ template ThreadProcWrapperBody(closure: expr) = # However this is doomed to fail, because we already unmapped every heap # page! + # mark as not running anymore: + t.emptyFn = nil + t.dataFn = nil + {.push stack_trace:off.} when defined(windows): proc threadProcWrapper[TMsg](closure: pointer): int32 {.stdcall.} = @@ -300,6 +304,10 @@ else: ThreadProcWrapperBody(closure) {.pop.} +proc running*[TMsg](t: TThread[TMsg]): bool {.inline.} = + ## returns true if `t` is running. + result = t.emptyFn == nil and t.dataFn == nil + proc joinThread*[TMsg](t: TThread[TMsg]) {.inline.} = ## waits for the thread `t` to finish. when hostOS == "windows": |