Closed bill-poole closed 3 months ago
It's just like the original zstd library, you need a different Compressor/Decompressor
object for each thread.
https://facebook.github.io/zstd/zstd_manual.html#Chapter4
Ah, excellent, thanks for pointing me to the relevant documentation.
Firstly, I'd like to thank you for creating this excellent library.!
I'm doing compression/decompression in a high performance environment, and as such I want to reuse each
Compressor
/Decompressor
object to compress/decompress many streams because there is an overhead with creating/initializing theCompressor
/Decompressor
objects. However, the library is throwing an exception saying the input Zstandard is corrupt if I reuse a singleDecompressor
object across multiple threads concurrently.I couldn't find any documentation saying whether the
Compressor
andDecompressor
objects are thread-safe. I assume based on the errors I'm getting that they are not. Is that correct? If so, do you recommend creating an instance of each per thread (using a[ThreadStatic]
attribute?Apologies if this is documented somewhere and I missed it.