Skip to content

C SDK: Document thread safety and fix js_cleanup#33

Closed
clemensv wants to merge 1 commit into
masterfrom
thread-safety-c
Closed

C SDK: Document thread safety and fix js_cleanup#33
clemensv wants to merge 1 commit into
masterfrom
thread-safety-c

Conversation

@clemensv
Copy link
Copy Markdown
Contributor

@clemensv clemensv commented Dec 9, 2025

Summary

Documents thread safety requirements for the C SDK and fixes js_cleanup() to properly clear the regex cache.

Changes

  • README.md: Add comprehensive Thread Safety section documenting:

    • Safe usage patterns (init once, cleanup once, thread-local results)
    • What is thread-safe (concurrent validation, regex cache)
    • What is NOT thread-safe (allocator changes during validation)
    • Multi-threaded usage example with pthreads
  • json_source_locator.c: Fix js_cleanup() to call js_regex_cache_clear() before resetting the allocator

Testing

  • Existing tests continue to pass
  • Thread safety tests should be added (tracked in issue)

Fixes #23

- Add Thread Safety section to README documenting safe usage patterns
- Fix js_cleanup() to call js_regex_cache_clear() before resetting allocator
- Document what is and isn't thread-safe

Fixes #23
@clemensv clemensv closed this Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C SDK: Document thread safety requirements and fix js_cleanup

1 participant