Simplify SharedArray.
This commit is contained in:
parent
7724336d73
commit
80ae938ddf
2 changed files with 2 additions and 8 deletions
|
|
@ -185,19 +185,13 @@ else:
|
|||
import locks
|
||||
|
||||
type
|
||||
SharedArrayHolder[T] = object
|
||||
part: array[1, T]
|
||||
SharedArray {.unchecked.}[T] = array[0..100_000_000, T]
|
||||
|
||||
proc allocSharedArray[T](nsize: int): ptr SharedArray[T] =
|
||||
let holder = cast[ptr SharedArrayHolder[T]](
|
||||
allocShared0(sizeof(T) * nsize)
|
||||
)
|
||||
result = cast[ptr SharedArray[T]](addr(holder.part[0]))
|
||||
result = cast[ptr SharedArray[T]](allocShared0(sizeof(T) & nsize))
|
||||
|
||||
proc deallocSharedArray[T](sa: ptr SharedArray[T]) =
|
||||
deallocShared(cast[pointer](sa))
|
||||
|
||||
type
|
||||
Event* {.pure.} = enum
|
||||
Read, Write, Timer, Signal, Process, Vnode, User, Error, Oneshot
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ when defined(macosx) or defined(freebsd):
|
|||
proc sysctl(name: ptr cint, namelen: cuint, oldp: pointer, oldplen: ptr int,
|
||||
newp: pointer, newplen: int): cint
|
||||
{.importc: "sysctl",header: """#include <sys/types.h>
|
||||
#include <sys/sysctl.h>"""}
|
||||
#include <sys/sysctl.h>"""}
|
||||
elif defined(netbsd) or defined(openbsd):
|
||||
# OpenBSD and NetBSD don't have KERN_MAXFILESPERPROC, so we are using
|
||||
# KERN_MAXFILES, because KERN_MAXFILES is always bigger,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue