From 7ad5cab17e742eaeb5a6910f79f5bbaaa5e4113c Mon Sep 17 00:00:00 2001 From: Araq Date: Thu, 11 Aug 2011 21:22:23 +0200 Subject: added system.running for threads --- lib/system/threads.nim | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/system') 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": -- cgit 1.4.1-2-gfad0