Is minizip thread safe? #399
-
By that I mean, can I safely spawn multiple threads, each using minizip concurrently to decompress a zip file (unique per thread) ? Or does minizip have an unprotected, internal global state that would prevent this use case ? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Potentially related: #375 |
Beta Was this translation helpful? Give feedback.
-
That's a different use case. I do not want to use multiple threads to concurrently decompress the same file. I want to run multiple instances of minizip concurrently, each operating on a different file. |
Beta Was this translation helpful? Give feedback.
-
As far as I know, minizip 2 is designed with a streaming model that avoids any global state usage. So I guess that dealing with separate files in separate folders (to avoid writing conflicts) could work. But don't take my words for granted: try it yourself or wait for Nathan answer. Note also that some file systems or hardwares aren't happy with writing two files at the same time, because it forces the hardware to frequently jump from one file to another: performances may be better when unzipping one file at a time. |
Beta Was this translation helpful? Give feedback.
-
Yes it is. |
Beta Was this translation helpful? Give feedback.
As far as I know, minizip 2 is designed with a streaming model that avoids any global state usage. So I guess that dealing with separate files in separate folders (to avoid writing conflicts) could work. But don't take my words for granted: try it yourself or wait for Nathan answer.
Note also that some file systems or hardwares aren't happy with writing two files at the same time, because it forces the hardware to frequently jump from one file to another: performances may be better when unzipping one file at a time.