mirror of
https://github.com/logos-messaging/nim-ffi.git
synced 2026-07-26 01:23:17 +00:00
more appropriate comment for requestRecycle
This commit is contained in:
parent
007629c254
commit
1667398f07
@ -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
|
||||
|
||||
|
||||
@ -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](
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user