more appropriate comment for requestRecycle

This commit is contained in:
Ivan FB 2026-06-05 18:13:00 +02:00
parent 007629c254
commit 1667398f07
No known key found for this signature in database
GPG Key ID: DF0C67A04C543270
2 changed files with 4 additions and 11 deletions

View File

@ -518,11 +518,11 @@ proc stopAndJoinThreads*[T](ctx: ptr FFIContext[T]): Result[void, string] =
proc requestRecycle*[T](
ctx: ptr FFIContext[T], callback: FFICallBack, userData: pointer
): Result[void, string] =
## Asks the FFI thread to recycle the context and fire `callback` with the
## outcome (RET_OK drained, RET_ERR stuck). NON-BLOCKING.
## Starts ctx recycle process without stopping its worker, so the next
## createFFIContext reuses the same threads and fds.
##
## Order matters: set the callback before flipping to RecyclePending (the flip is
## the trigger), under `lock` to serialise the gate with sendRequestToFFIThread.
## During recycling, the FFI thread drains the handlers, frees the lib and releases
## the context, then fires `callback` (RET_OK drained, RET_ERR stuck).
ctx.recycleCallback = callback
ctx.recycleUserData = userData

View File

@ -45,13 +45,6 @@ proc createFFIContext*[T](
proc releaseFFIContext*[T](
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
## for the generated destructor; destroyFFIContext is for failure/non-pool use.
##
## NON-BLOCKING: the FFI thread drains the handlers, frees the lib and releases
## the context, then fires `callback` (RET_OK drained, RET_ERR stuck). The context
## returns to the pool from that thread, so a reused context never carries a straggler.
return ctx.requestRecycle(callback, userData)
proc destroyFFIContext*[T](