std/private/threadtypes

Source   Edit  

Types

CpuSet {.importc: "cpu_set_t", header: "#define _GNU_SOURCE\n#include <sched.h>".} = object
  when defined(linux) and defined(amd64):
    
  
Source   Edit  
GcThread {.pure, inheritable.} = object
  when emulatedThreadVars:
      tls*: ThreadLocalStorage

  else:
      nil

  when hasSharedHeap:
      next*, prev*: PGcThread
      stackBottom*, stackTop*: pointer
      stackSize*: int

  else:
      nil

  
Source   Edit  
PGcThread = ptr GcThread
Source   Edit  
Pthread_attr {.importc: "pthread_attr_t", header: "<sys/types.h>".} = object
  
Source   Edit  
SysThread {.importc: "pthread_t", header: "<sys/types.h>".} = distinct culong
Source   Edit  
Thread[TArg] = object
  core*: PGcThread
  sys*: SysThread
  when TArg is void:
      dataFn*: proc () {.nimcall, ...gcsafe.}

  else:
      dataFn*: proc (m: TArg) {.nimcall, ...gcsafe.}
      data*: TArg

  when hasAllocStack:
      rawStack*: pointer

  
Source   Edit  
ThreadLocalStorage = array[0 .. (nimTlsSize div 8), float]
Source   Edit  
Timespec {.importc: "struct timespec", header: "<time.h>".} = object
  tv_sec*: Time
  tv_nsec*: clong
Source   Edit  

Consts

emulatedThreadVars = false
Source   Edit  
hasAllocStack = false
Source   Edit  
hasSharedHeap = false
Source   Edit  
pthreadh = "#define _GNU_SOURCE\n#include <pthread.h>"
Source   Edit  

Procs

proc `=copy`[TArg](x: var Thread[TArg]; y: Thread[TArg]) {.error.}
Source   Edit  
proc cpusetIncl(cpu: cint; s: var CpuSet) {.importc: "CPU_SET",
    header: "#define _GNU_SOURCE\n#include <sched.h>", ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc cpusetZero(s: var CpuSet) {.importc: "CPU_ZERO", header: "#define _GNU_SOURCE\n#include <sched.h>",
                                 ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc pthread_attr_destroy(a1: var Pthread_attr): cint {.importc,
    header: "#define _GNU_SOURCE\n#include <pthread.h>", ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc pthread_attr_init(a1: var Pthread_attr): cint {.importc,
    header: "#define _GNU_SOURCE\n#include <pthread.h>", ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc pthread_attr_setstack(a1: ptr Pthread_attr; a2: pointer; a3: int): cint {.
    importc, header: "#define _GNU_SOURCE\n#include <pthread.h>", ...raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc pthread_attr_setstacksize(a1: var Pthread_attr; a2: int): cint {.importc,
    header: "#define _GNU_SOURCE\n#include <pthread.h>", ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc pthread_cancel(a1: SysThread): cint {.importc: "pthread_cancel",
    header: "#define _GNU_SOURCE\n#include <pthread.h>", ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc pthread_create(a1: var SysThread; a2: var Pthread_attr;
                    a3: proc (x: pointer): pointer {.noconv.}; a4: pointer): cint {.
    importc: "pthread_create",
    header: "#define _GNU_SOURCE\n#include <pthread.h>", ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc pthread_join(a1: SysThread; a2: ptr pointer): cint {.importc,
    header: "#define _GNU_SOURCE\n#include <pthread.h>", ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc setAffinity(thread: SysThread; setsize: csize_t; s: var CpuSet) {.
    importc: "pthread_setaffinity_np",
    header: "#define _GNU_SOURCE\n#include <pthread.h>", ...raises: [], tags: [],
    forbids: [].}
Source   Edit