From ea0319940010fd10b2c2ea4db8373df4dafeecdc Mon Sep 17 00:00:00 2001 From: coffeepots Date: Wed, 27 Jul 2016 14:56:52 +0100 Subject: Add handle function to Thread type Exposes SysThread type and introduces the function "handle" to return Thread.sys. --- lib/system/threads.nim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') 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: "", + SysThread* {.importc: "pthread_t", header: "", final, pure.} = object Pthread_attr {.importc: "pthread_attr_t", header: "", 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. -- cgit 1.4.1-2-gfad0