Add limitation doc

This commit is contained in:
Arnaud 2025-09-11 14:55:44 +02:00
parent 24359d409e
commit 56dc449096
No known key found for this signature in database
GPG Key ID: B8FBC178F10CA7AE
2 changed files with 10 additions and 0 deletions

View File

@ -91,6 +91,10 @@ Run the example:
By default, Codex builds a dynamic library (`libcodex.so`), which you can load at runtime.
If you prefer a static library (`libcodex.a`), set the `STATIC` flag:
### Limitation
Callbacks must be fast and non-blocking; otherwise, the working thread will hang and prevent other requests from being processed.
```bash
# Build dynamic (default)
make libcodex

View File

@ -40,6 +40,12 @@ proc createShared*(
ret[].userData = userData
return ret
# NOTE: User callbacks are executed on the working thread.
# They must be fast and non-blocking; otherwise this thread will be blocked
# and no further requests can be processed.
# We can improve this by dispatching the callbacks to a thread pool or
# moving to a MP channel.
# See: https://github.com/codex-storage/nim-codex/pull/1322#discussion_r2340708316
proc handleRes[T: string | void](
res: Result[T, string], request: ptr CodexThreadRequest
) =