diff options
author | Araq <rumpf_a@web.de> | 2010-11-18 22:56:09 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2010-11-18 22:56:09 +0100 |
commit | ee445dc02297802136b5005408f6807820864c7f (patch) | |
tree | 5d1f1951fa077d0a36cbb0fd52e4a375ab6970b5 /lib | |
parent | adf13aaea379d482ad4289d349a9d475bc2c06a6 (diff) | |
download | Nim-ee445dc02297802136b5005408f6807820864c7f.tar.gz |
renamed lock->aquire
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/system/gc.nim | 32 | ||||
-rwxr-xr-x | lib/system/systhread.nim | 8 |
2 files changed, 20 insertions, 20 deletions
diff --git a/lib/system/gc.nim b/lib/system/gc.nim index aca3705cd..72ae84096 100755 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -76,17 +76,17 @@ var # This is wasteful but safe. This is a lock against recursive garbage # collection, not a lock for threads! -proc lock(gch: var TGcHeap) {.inline.} = +proc aquire(gch: var TGcHeap) {.inline.} = when hasThreadSupport: if isMultiThreaded: - Lock(gch.zctLock) - lock(gch.cycleRootsLock) + aquire(gch.zctLock) + aquire(gch.cycleRootsLock) -proc unlock(gch: var TGcHeap) {.inline.} = +proc release(gch: var TGcHeap) {.inline.} = when hasThreadSupport: if isMultiThreaded: - unlock(gch.zctLock) - unlock(gch.cycleRootsLock) + release(gch.zctLock) + release(gch.cycleRootsLock) proc addZCT(s: var TCellSeq, c: PCell) {.noinline.} = if (c.refcount and rcZct) == 0: @@ -205,18 +205,18 @@ proc prepareDealloc(cell: PCell) = proc rtlAddCycleRoot(c: PCell) {.rtl, inl.} = # we MUST access gch as a global here, because this crosses DLL boundaries! when hasThreadSupport: - if isMultiThreaded: Lock(gch.cycleRootsLock) + if isMultiThreaded: Aquire(gch.cycleRootsLock) incl(gch.cycleRoots, c) when hasThreadSupport: - if isMultiThreaded: Unlock(gch.cycleRootsLock) + if isMultiThreaded: Release(gch.cycleRootsLock) proc rtlAddZCT(c: PCell) {.rtl, inl.} = # we MUST access gch as a global here, because this crosses DLL boundaries! when hasThreadSupport: - if isMultiThreaded: Lock(gch.zctLock) + if isMultiThreaded: Aquire(gch.zctLock) addZCT(gch.zct, c) when hasThreadSupport: - if isMultiThreaded: Unlock(gch.zctLock) + if isMultiThreaded: Release(gch.zctLock) proc decRef(c: PCell) {.inline.} = when stressGC: @@ -333,7 +333,7 @@ proc checkCollection {.inline.} = proc newObj(typ: PNimType, size: int): pointer {.compilerRtl.} = # generates a new object and sets its reference counter to 0 - lock(gch) + aquire(gch) assert(typ.kind in {tyRef, tyString, tySequence}) checkCollection() var res = cast[PCell](rawAlloc(allocator, size + sizeof(TCell))) @@ -362,7 +362,7 @@ proc newObj(typ: PNimType, size: int): pointer {.compilerRtl.} = add(gch.zct, res) when logGC: writeCell("new cell", res) gcTrace(res, csAllocated) - unlock(gch) + release(gch) result = cellToUsr(res) proc newSeq(typ: PNimType, len: int): pointer {.compilerRtl.} = @@ -372,7 +372,7 @@ proc newSeq(typ: PNimType, len: int): pointer {.compilerRtl.} = cast[PGenericSeq](result).space = len proc growObj(old: pointer, newsize: int): pointer {.rtl.} = - lock(gch) + aquire(gch) checkCollection() var ol = usrToCell(old) assert(ol.typ != nil) @@ -410,7 +410,7 @@ proc growObj(old: pointer, newsize: int): pointer {.rtl.} = else: assert(ol.typ != nil) zeroMem(ol, sizeof(TCell)) - unlock(gch) + release(gch) result = cellToUsr(res) # ---------------- cycle collector ------------------------------------------- @@ -679,12 +679,12 @@ when not defined(useNimRtl): # set to the max value to suppress the cycle detector proc GC_fullCollect() = - lock(gch) + aquire(gch) var oldThreshold = cycleThreshold cycleThreshold = 0 # forces cycle collection collectCT(gch) cycleThreshold = oldThreshold - unlock(gch) + release(gch) proc GC_getStatistics(): string = GC_disable() diff --git a/lib/system/systhread.nim b/lib/system/systhread.nim index af001985e..82ffd72ce 100755 --- a/lib/system/systhread.nim +++ b/lib/system/systhread.nim @@ -58,9 +58,9 @@ when defined(Windows): proc InitLock(L: var TSysLock) {.stdcall, dynlib: "kernel32", importc: "InitializeCriticalSection".} - proc Lock(L: var TSysLock) {.stdcall, + proc Aquire(L: var TSysLock) {.stdcall, dynlib: "kernel32", importc: "EnterCriticalSection".} - proc Unlock(L: var TSysLock) {.stdcall, + proc Release(L: var TSysLock) {.stdcall, dynlib: "kernel32", importc: "LeaveCriticalSection".} proc CreateThread(lpThreadAttributes: Pointer, dwStackSize: int32, @@ -76,9 +76,9 @@ else: proc InitLock(L: var TSysLock, attr: pointer = nil) {. importc: "pthread_mutex_init", header: "<pthread.h>".} - proc Lock(L: var TSysLock) {. + proc Aquire(L: var TSysLock) {. importc: "pthread_mutex_lock", header: "<pthread.h>".} - proc Unlock(L: var TSysLock) {. + proc Release(L: var TSysLock) {. importc: "pthread_mutex_unlock", header: "<pthread.h>".} |