diff options
author | coffeepots <coffeepots@users.noreply.github.com> | 2016-07-27 14:56:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-27 14:56:52 +0100 |
commit | ea0319940010fd10b2c2ea4db8373df4dafeecdc (patch) | |
tree | d85d28beb793a9be1a13d4df0351dd4e2b223eed /lib | |
parent | be22071b2e4c4233f074132b48f1687051fb2fd9 (diff) | |
download | Nim-ea0319940010fd10b2c2ea4db8373df4dafeecdc.tar.gz |
Add handle function to Thread type
Exposes SysThread type and introduces the function "handle" to return Thread.sys.
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. |