mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-30 18:41:45 +00:00
added system.running for threads
This commit is contained in:
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user