Add thread enter/exit callbacks

This commit is contained in:
Ruslan Mustakov 2017-07-26 17:50:36 +07:00
commit 3a6acbbe92
3 changed files with 21 additions and 1 deletions

View file

@ -554,4 +554,16 @@ proc godot_gdnative_init(options: ptr GodotNativeInitOptions) {.
proc godot_gdnative_terminate(options: ptr GodotNativeTerminateOptions) {.
cdecl, exportc, dynlib.} =
deallocHeap()
deallocHeap(runFinalizers = true, allowGcAfterwards = false)
proc godot_nativescript_thread_enter() {.
cdecl, exportc, dynlib.} =
when compileOption("threads"):
setupForeignThreadGc()
else:
print(cstring"A foreign thread is created, but app is compiled without --threads:on. Bad things will happen if Nim code is invoked from this thread.")
proc godot_nativescript_thread_exit() {.
cdecl, exportc, dynlib.} =
when compileOption("threads"):
teardownForeignThreadGc()