mirror of
https://github.com/logos-messaging/nim-ffi.git
synced 2026-05-16 07:09:30 +00:00
better resource cleanup in destroyFFIContext
This commit is contained in:
parent
66ef92ad26
commit
53b91e1354
@ -229,16 +229,16 @@ proc createFFIContext*[T](): Result[ptr FFIContext[T], string] =
|
||||
|
||||
proc destroyFFIContext*[T](ctx: ptr FFIContext[T]): Result[void, string] =
|
||||
ctx.running.store(false)
|
||||
defer:
|
||||
joinThread(ctx.ffiThread)
|
||||
joinThread(ctx.watchdogThread)
|
||||
ctx.cleanUpResources()
|
||||
|
||||
let signaledOnTime = ctx.reqSignal.fireSync().valueOr:
|
||||
return err("error in destroyFFIContext: " & $error)
|
||||
if not signaledOnTime:
|
||||
return err("failed to signal reqSignal on time in destroyFFIContext")
|
||||
|
||||
joinThread(ctx.ffiThread)
|
||||
joinThread(ctx.watchdogThread)
|
||||
ctx.cleanUpResources()
|
||||
|
||||
return ok()
|
||||
|
||||
template checkParams*(ctx: ptr FFIContext, callback: FFICallBack, userData: pointer) =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user