diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/concurrency/threadpool.nim | 2 | ||||
-rw-r--r-- | lib/pure/random.nim | 2 | ||||
-rw-r--r-- | lib/std/threads.nim | 10 | ||||
-rw-r--r-- | lib/system.nim | 7 | ||||
-rw-r--r-- | lib/system/threadimpl.nim | 9 |
5 files changed, 15 insertions, 15 deletions
diff --git a/lib/pure/concurrency/threadpool.nim b/lib/pure/concurrency/threadpool.nim index 5d9e7452b..50f3be1ea 100644 --- a/lib/pure/concurrency/threadpool.nim +++ b/lib/pure/concurrency/threadpool.nim @@ -24,7 +24,7 @@ when not compileOption("threads"): import cpuinfo, cpuload, locks, os when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, threads] {.push stackTrace:off.} diff --git a/lib/pure/random.nim b/lib/pure/random.nim index de93f468f..9418924da 100644 --- a/lib/pure/random.nim +++ b/lib/pure/random.nim @@ -76,7 +76,7 @@ import algorithm, math import std/private/since when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions] include system/inclrtl {.push debugger: off.} diff --git a/lib/std/threads.nim b/lib/std/threads.nim index 5726a5cdc..358ff0d9e 100644 --- a/lib/std/threads.nim +++ b/lib/std/threads.nim @@ -95,16 +95,6 @@ when defined(zephyr): -proc onThreadDestruction*(handler: proc () {.closure, gcsafe, raises: [].}) = - ## Registers a *thread local* handler that is called at the thread's - ## destruction. - ## - ## A thread is destructed when the `.thread` proc returns - ## normally or when it raises an exception. Note that unhandled exceptions - ## in a thread nevertheless cause the whole process to die. - nimThreadDestructionHandlers.add handler - - {.push stack_trace:off.} when defined(windows): proc threadProcWrapper[TArg](closure: pointer): int32 {.stdcall.} = diff --git a/lib/system.nim b/lib/system.nim index ff2bff45f..68645cea0 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2093,9 +2093,10 @@ when not defined(js): when hasThreadSupport: when hostOS != "standalone": include system/threadimpl - - import std/threads - export threads + when not defined(nimPreviewSlimSystem): + {.deprecated: "threads is about to move out of system; use `-d:nimPreviewSlimSystem` and import `std/threads`".} + import std/threads + export threads elif not defined(nogc) and not defined(nimscript): when not defined(useNimRtl) and not defined(createNimRtl): initStackBottom() diff --git a/lib/system/threadimpl.nim b/lib/system/threadimpl.nim index 73f2807d2..94db23336 100644 --- a/lib/system/threadimpl.nim +++ b/lib/system/threadimpl.nim @@ -33,6 +33,15 @@ template afterThreadRuns() = for i in countdown(nimThreadDestructionHandlers.len-1, 0): nimThreadDestructionHandlers[i]() +proc onThreadDestruction*(handler: proc () {.closure, gcsafe, raises: [].}) = + ## Registers a *thread local* handler that is called at the thread's + ## destruction. + ## + ## A thread is destructed when the `.thread` proc returns + ## normally or when it raises an exception. Note that unhandled exceptions + ## in a thread nevertheless cause the whole process to die. + nimThreadDestructionHandlers.add handler + when defined(boehmgc): type GCStackBaseProc = proc(sb: pointer, t: pointer) {.noconv.} proc boehmGC_call_with_stack_base(sbp: GCStackBaseProc, p: pointer) |