diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-07-27 18:03:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-27 18:03:24 +0200 |
commit | 27a40cd5a43175d273bf15af0ce0c269ea76a49b (patch) | |
tree | d85d28beb793a9be1a13d4df0351dd4e2b223eed /lib | |
parent | be22071b2e4c4233f074132b48f1687051fb2fd9 (diff) | |
parent | ea0319940010fd10b2c2ea4db8373df4dafeecdc (diff) | |
download | Nim-27a40cd5a43175d273bf15af0ce0c269ea76a49b.tar.gz |
Merge pull request #4522 from coffeepots/patch-2
Add handle function to Thread type
Diffstat (limited to 'lib')
-rw-r--r-- | lib/system/threads.nim | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/system/threads.nim b/lib/system/threads.nim index cc9da0a92..583e3ae86 100644 --- a/lib/system/threads.nim +++ b/lib/system/threads.nim @@ -51,7 +51,7 @@ const when defined(windows): type - SysThread = Handle + SysThread* = Handle WinThreadProc = proc (x: pointer): int32 {.stdcall.} {.deprecated: [TSysThread: SysThread, TWinThreadProc: WinThreadProc].} @@ -123,7 +123,7 @@ else: type Time = int type - SysThread {.importc: "pthread_t", header: "<sys/types.h>", + SysThread* {.importc: "pthread_t", header: "<sys/types.h>", final, pure.} = object Pthread_attr {.importc: "pthread_attr_t", header: "<sys/types.h>", final, pure.} = object @@ -379,6 +379,10 @@ proc running*[TArg](t: Thread[TArg]): bool {.inline.} = ## returns true if `t` is running. result = t.dataFn != nil +proc handle*[TArg](t: Thread[TArg]): SysThread {.inline.} = + ## returns the thread handle of `t`. + result = t.sys + when hostOS == "windows": proc joinThread*[TArg](t: Thread[TArg]) {.inline.} = ## waits for the thread `t` to finish. |