Skip to main content

Module threads

Module threads 

Source
Expand description

Threading support (§57, §93, §85 Phase 1).

Thread-local state, concurrent parsing, concurrent transformation, shared immutable dictionaries, callback isolation.

§UPSTREAM-PARITY

libxml2’s threading support provides:

  • xmlInitThreads() / xmlCleanupThreads() — lifecycle
  • xmlLockLibrary() / xmlUnlockLibrary() — global lock
  • Thread-local storage for error state and parser contexts

In modern libxml2 (2.12+), threading is initialized automatically by xmlInitParser. The explicit thread functions exist for backward compatibility.

In Rust, we use standard thread-safe primitives and thread_local! for thread-local storage. The global lock is a no-op since Rust’s type system prevents data races at compile time.

§Phase 1 status

Complete — all threading support is implemented.

Functions§

cleanup_threads
Clean up threading support.
get_thread_count
Get the number of active threads (for compatibility).
init_threads
Initialize threading support.
lock_library
Lock the library (global mutex).
threads_initialized
Check whether threading has been initialized.
unlock_library
Unlock the library.