better resource cleanup in destroyFFIContext

This commit is contained in:
Ivan FB 2026-04-24 13:30:31 +02:00
parent 66ef92ad26
commit 53b91e1354
No known key found for this signature in database
GPG Key ID: DF0C67A04C543270

View File

@ -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) =