diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2022-10-31 13:36:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-31 06:36:50 +0100 |
commit | e1ddd2d524e3e57df25d6498d275f019e450111e (patch) | |
tree | 9d531ffc00e74da2569977b792a8b3304f25c919 /lib/system | |
parent | fb2ec8d192cbaa36868f28275993936868ba2d31 (diff) | |
download | Nim-e1ddd2d524e3e57df25d6498d275f019e450111e.tar.gz |
put std/threads under the umbrella of nimPreviewSlimSystem (#20711)
* put `std/threads` under the umbrella of `nimPreviewSlimSystem` * add changelog * fixes tests * fixes tests again * fixes tests
Diffstat (limited to 'lib/system')
-rw-r--r-- | lib/system/threadimpl.nim | 9 |
1 files changed, 9 insertions, 0 deletions
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) |