diff options
author | Araq <rumpf_a@web.de> | 2011-08-11 21:22:23 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-08-11 21:22:23 +0200 |
commit | 7ad5cab17e742eaeb5a6910f79f5bbaaa5e4113c (patch) | |
tree | c43ded120e419fbe9f3c5ee7356b0eed92b0098d /lib/system | |
parent | a1cdd6e7ffbefb7f1e64847426b3e424656c6291 (diff) | |
download | Nim-7ad5cab17e742eaeb5a6910f79f5bbaaa5e4113c.tar.gz |
added system.running for threads
Diffstat (limited to 'lib/system')
-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": |