Merge pull request #2891 from sstirlin/devel
fixed threadpool and atomics to work with Visual Studio 32 and 64 bit
This commit is contained in:
commit
a9e791823e
2 changed files with 4 additions and 3 deletions
|
|
@ -290,7 +290,8 @@ proc slave(w: ptr Worker) {.thread.} =
|
||||||
readyWorker = w
|
readyWorker = w
|
||||||
signal(gSomeReady)
|
signal(gSomeReady)
|
||||||
await(w.taskArrived)
|
await(w.taskArrived)
|
||||||
assert(not w.ready)
|
# XXX Somebody needs to look into this (why does this assertion fail in Visual Studio?)
|
||||||
|
when not defined(vcc): assert(not w.ready)
|
||||||
w.f(w, w.data)
|
w.f(w, w.data)
|
||||||
if w.q.len != 0: w.cleanFlowVars
|
if w.q.len != 0: w.cleanFlowVars
|
||||||
if w.shutdown:
|
if w.shutdown:
|
||||||
|
|
|
||||||
|
|
@ -191,11 +191,11 @@ proc atomicDec*(memLoc: var int, x: int = 1): int =
|
||||||
result = memLoc
|
result = memLoc
|
||||||
|
|
||||||
when defined(windows) and not someGcc:
|
when defined(windows) and not someGcc:
|
||||||
proc interlockedCompareExchange(p: pointer; exchange, comparand: int32): int32
|
proc interlockedCompareExchange(p: pointer; exchange, comparand: int): int
|
||||||
{.importc: "InterlockedCompareExchange", header: "<windows.h>", cdecl.}
|
{.importc: "InterlockedCompareExchange", header: "<windows.h>", cdecl.}
|
||||||
|
|
||||||
proc cas*[T: bool|int|ptr](p: ptr T; oldValue, newValue: T): bool =
|
proc cas*[T: bool|int|ptr](p: ptr T; oldValue, newValue: T): bool =
|
||||||
interlockedCompareExchange(p, newValue.int32, oldValue.int32) != 0
|
interlockedCompareExchange(p, cast[int](newValue), cast[int](oldValue)) != 0
|
||||||
# XXX fix for 64 bit build
|
# XXX fix for 64 bit build
|
||||||
else:
|
else:
|
||||||
# this is valid for GCC and Intel C++
|
# this is valid for GCC and Intel C++
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue