added getTotalSharedMem et al.
This commit is contained in:
parent
e54ab22bf9
commit
f5ed8f3a1b
2 changed files with 30 additions and 0 deletions
|
|
@ -1434,6 +1434,20 @@ when not defined(nimrodVM) and hostOS != "standalone":
|
|||
proc getTotalMem*(): int {.rtl.}
|
||||
## returns the number of bytes that are owned by the process.
|
||||
|
||||
when hasThreadSupport:
|
||||
proc getOccupiedSharedMem*(): int {.rtl.}
|
||||
## returns the number of bytes that are owned by the process
|
||||
## on the shared heap and hold data. This is only available when
|
||||
## threads are enabled.
|
||||
|
||||
proc getFreeSharedMem*(): int {.rtl.}
|
||||
## returns the number of bytes that are owned by the
|
||||
## process on the shared heap, but do not hold any meaningful data.
|
||||
## This is only available when threads are enabled.
|
||||
|
||||
proc getTotalSharedMem*(): int {.rtl.}
|
||||
## returns the number of bytes on the shared heap that are owned by the
|
||||
## process. This is only available when threads are enabled.
|
||||
|
||||
iterator countdown*[T](a, b: T, step = 1): T {.inline.} =
|
||||
## Counts from ordinal value `a` down to `b` with the given
|
||||
|
|
|
|||
|
|
@ -835,4 +835,20 @@ template instantiateForRegion(allocator: expr) =
|
|||
else:
|
||||
result = realloc(p, newsize)
|
||||
|
||||
when hasThreadSupport:
|
||||
|
||||
template sharedMemStatsShared(v: int) {.immediate.} =
|
||||
acquireSys(heapLock)
|
||||
result = v
|
||||
releaseSys(heapLock)
|
||||
|
||||
proc getFreeSharedMem(): int =
|
||||
sharedMemStatsShared(sharedHeap.freeMem)
|
||||
|
||||
proc getTotalSharedMem(): int =
|
||||
sharedMemStatsShared(sharedHeap.currMem)
|
||||
|
||||
proc getOccupiedSharedMem(): int =
|
||||
sharedMemStatsShared(sharedHeap.currMem - sharedHeap.freeMem)
|
||||
|
||||
{.pop.}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue