Skip to content

Commit

Permalink
docs: expand thread safety documentation to cover derived values
Browse files Browse the repository at this point in the history
Closes #166.
  • Loading branch information
indygreg committed Jan 17, 2022
1 parent 712d113 commit 0cc3af3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/api_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,22 @@ about thread safety. Do not operate on the same ``ZstdCompressor`` and
fine to have different threads call into a single instance, just not at the
same time.

Objects derived from ``ZstdCompressor`` and ``ZstdDecompressor`` that
perform (de)compression operations (such as ``ZstdCompressionReader`` and
``ZstdDecompressionWriter``) are bound to the ``ZstdCompressor`` or
``ZstdDecompressor`` from which they came and are therefore not thread safe
by extension.

Some operations require multiple function calls to complete. e.g. streaming
operations. A single ``ZstdCompressor`` or ``ZstdDecompressor`` cannot be used
for simultaneously active operations. e.g. you must not start a streaming
operation when another streaming operation is already active.

If you need to perform multiple compression or decompression operations in
parallel, you MUST construct multiple ``ZstdCompressor`` or ``ZstdDecompressor``
instances so each independent operation has its own ``ZstdCompressor`` or
``ZstdDecompressor`` instance.

The C extension releases the GIL during non-trivial calls into the zstd C
API. Non-trivial calls are notably compression and decompression. Trivial
calls are things like parsing frame parameters. Where the GIL is released
Expand Down
3 changes: 3 additions & 0 deletions docs/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ Changes
backend. (#165)
* ``ZstdCompressionWriter`` and ``ZstdDecompressionWriter`` now implement
``__iter__`` and ``__next__``, which always raise ``io.UnsupportedOperation``.
* Documentation on thread safety has been updated to note that derived objects
like ``ZstdCompressionWriter`` have the same thread unsafety as the contexts
they were derived from. (#166)

0.16.0 (released 2021-10-16)
============================
Expand Down

0 comments on commit 0cc3af3

Please sign in to comment.