Add try and finally to make sure teardown is called

This commit is contained in:
Arnaud 2026-06-01 15:16:41 +04:00
parent bf0ace8da2
commit 9867ec4787
No known key found for this signature in database
GPG Key ID: A6C7C781817146FA

View File

@ -79,9 +79,11 @@ type
template foreignThreadGc(body: untyped) = template foreignThreadGc(body: untyped) =
when declared(setupForeignThreadGc): when declared(setupForeignThreadGc):
setupForeignThreadGc() setupForeignThreadGc()
body try:
when declared(tearDownForeignThreadGc): body
tearDownForeignThreadGc() finally:
when declared(tearDownForeignThreadGc):
tearDownForeignThreadGc()
var activeMappingsLock: Lock var activeMappingsLock: Lock
var activeMappings {.guard: activeMappingsLock.}: Table[cint, MappingHandle] var activeMappings {.guard: activeMappingsLock.}: Table[cint, MappingHandle]