diff options
author | Araq <rumpf_a@web.de> | 2014-10-11 21:02:08 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-10-11 21:02:08 +0200 |
commit | 826d529256a51f15942685e6533faf5040605d18 (patch) | |
tree | 053aaa7758092d31fa7471c2793e062ae01b8c14 /lib/pure/concurrency | |
parent | 6a29fbf240e9395588dcf048ddd3037144c52e12 (diff) | |
parent | 34e96e37a12083e64be3842f5fc76fd795328e4a (diff) | |
download | Nim-826d529256a51f15942685e6533faf5040605d18.tar.gz |
Merge branch 'devel' of https://github.com/Araq/Nimrod into devel
Diffstat (limited to 'lib/pure/concurrency')
-rw-r--r-- | lib/pure/concurrency/cpuinfo.nim | 8 | ||||
-rw-r--r-- | lib/pure/concurrency/threadpool.nim | 6 |
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/pure/concurrency/cpuinfo.nim b/lib/pure/concurrency/cpuinfo.nim index dfa819f64..bd10a416f 100644 --- a/lib/pure/concurrency/cpuinfo.nim +++ b/lib/pure/concurrency/cpuinfo.nim @@ -18,6 +18,12 @@ when not defined(windows): when defined(linux): import linux + +when defined(freebsd) or defined(macosx): + {.emit:"#include <sys/types.h>".} + +when defined(openbsd) or defined(netbsd): + {.emit:"#include <sys/param.h>".} when defined(macosx) or defined(bsd): const @@ -26,7 +32,7 @@ when defined(macosx) or defined(bsd): HW_NCPU = 3 proc sysctl(x: ptr array[0..3, cint], y: cint, z: pointer, a: var csize, b: pointer, c: int): cint {. - importc: "sysctl", header: "<sys/sysctl.h>".} + importc: "sysctl", header: "<sys/sysctl.h>".} proc countProcessors*(): int {.rtl, extern: "ncpi$1".} = ## returns the numer of the processors/cores the machine has. diff --git a/lib/pure/concurrency/threadpool.nim b/lib/pure/concurrency/threadpool.nim index e0a2ac678..f46822d94 100644 --- a/lib/pure/concurrency/threadpool.nim +++ b/lib/pure/concurrency/threadpool.nim @@ -95,7 +95,7 @@ type FlowVarBase* = ref FlowVarBaseObj ## untyped base class for 'FlowVar[T]' FlowVarBaseObj = object of TObject - ready, usesCondVar: bool + ready, usesCondVar, awaited: bool cv: CondVar #\ # for 'awaitAny' support ai: ptr AwaitInfo @@ -129,8 +129,8 @@ type proc await*(fv: FlowVarBase) = ## waits until the value for the flowVar arrives. Usually it is not necessary ## to call this explicitly. - if fv.usesCondVar: - fv.usesCondVar = false + if fv.usesCondVar and not fv.awaited: + fv.awaited = true await(fv.cv) destroyCondVar(fv.cv) |