mirror of
https://github.com/logos-messaging/nim-ffi.git
synced 2026-06-21 08:49:34 +00:00
remove unused param in releaseFFIContext proc in ffi_context_pool.nim
This commit is contained in:
parent
5f76d1fa5b
commit
6c4bbe01cd
@ -43,10 +43,7 @@ proc createFFIContext*[T](
|
||||
return err("FFI context pool exhausted (max " & $MaxFFIContexts & " contexts)")
|
||||
|
||||
proc releaseFFIContext*[T](
|
||||
pool: var FFIContextPool[T],
|
||||
ctx: ptr FFIContext[T],
|
||||
callback: FFICallBack,
|
||||
userData: pointer,
|
||||
ctx: ptr FFIContext[T], callback: FFICallBack, userData: pointer
|
||||
): Result[void, string] =
|
||||
## Parks a context for reuse without stopping its worker, so the next
|
||||
## createFFIContext reuses the same threads and fds. Steady-state cleanup path
|
||||
|
||||
@ -1567,7 +1567,7 @@ macro ffiDtor*(prc: untyped): untyped =
|
||||
|
||||
let poolIdent = ident($libTypeName & "FFIPool")
|
||||
ffiBody.add quote do:
|
||||
let `destroyResIdent` = `poolIdent`.releaseFFIContext(
|
||||
let `destroyResIdent` = releaseFFIContext(
|
||||
cast[ptr FFIContext[`libTypeName`]](ctx), callback, userData
|
||||
)
|
||||
if `destroyResIdent`.isErr():
|
||||
|
||||
@ -795,7 +795,7 @@ proc countOpenFds(): int =
|
||||
except CatchableError:
|
||||
return -1
|
||||
|
||||
proc releaseAndWait[T](pool: var FFIContextPool[T], ctx: ptr FFIContext[T]): cint =
|
||||
proc releaseAndWait[T](ctx: ptr FFIContext[T]): cint =
|
||||
## Test helper mirroring how a C consumer destroys a context: kick off the
|
||||
## (non-blocking) teardown and block on the callback, returning its retCode.
|
||||
## RET_OK means the lib's in-flight tasks finished and the slot was parked.
|
||||
@ -803,7 +803,7 @@ proc releaseAndWait[T](pool: var FFIContextPool[T], ctx: ptr FFIContext[T]): cin
|
||||
initCallbackData(d)
|
||||
defer:
|
||||
deinitCallbackData(d)
|
||||
if pool.releaseFFIContext(ctx, testCallback, addr d).isErr():
|
||||
if ctx.releaseFFIContext(testCallback, addr d).isErr():
|
||||
return RET_ERR
|
||||
waitCallback(d)
|
||||
return d.retCode
|
||||
@ -814,7 +814,7 @@ suite "releaseFFIContext (park & reuse)":
|
||||
let ctx1 = pool.createFFIContext().valueOr:
|
||||
check false
|
||||
return
|
||||
check pool.releaseAndWait(ctx1) == RET_OK
|
||||
check ctx1.releaseAndWait() == RET_OK
|
||||
|
||||
# Reacquire: must be the same array slot, with its worker still running.
|
||||
let ctx2 = pool.createFFIContext().valueOr:
|
||||
@ -843,7 +843,7 @@ suite "releaseFFIContext (park & reuse)":
|
||||
ctx.callbackState.callback = cast[pointer](testCallback)
|
||||
ctx.callbackState.userData = cast[pointer](0xDEAD)
|
||||
|
||||
check pool.releaseAndWait(ctx) == RET_OK
|
||||
check ctx.releaseAndWait() == RET_OK
|
||||
check ctx.callbackState.callback.isNil() # a watchdog tick can't call a freed cb
|
||||
check ctx.callbackState.userData.isNil()
|
||||
check ctx.myLib.isNil()
|
||||
@ -862,7 +862,7 @@ suite "releaseFFIContext (park & reuse)":
|
||||
let ctx = pool.createFFIContext().valueOr:
|
||||
check false
|
||||
return
|
||||
check pool.releaseAndWait(ctx) == RET_OK
|
||||
check ctx.releaseAndWait() == RET_OK
|
||||
|
||||
let baseline = countOpenFds()
|
||||
|
||||
@ -877,7 +877,7 @@ suite "releaseFFIContext (park & reuse)":
|
||||
).isOk()
|
||||
waitCallback(d)
|
||||
deinitCallbackData(d)
|
||||
check pool.releaseAndWait(ctx) == RET_OK
|
||||
check ctx.releaseAndWait() == RET_OK
|
||||
|
||||
let afterCycles = countOpenFds()
|
||||
# Reuse must not grow fds. Before the fix each cycle leaked ~10 fds (4
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user