rillian / tiff2png

Tiff to png conversion utility (forked from libpng.org)
10 stars 2 forks source link

Multithreading this program #1

Open yarafatin opened 9 years ago

yarafatin commented 9 years ago

Is this program thread-safe? This is a very nice utility you have. I will give it a try. I am planning to use it in a system which may need conversions on the fly to render on the browser. There may be million transactions occurring in an hour and it needs to be thread safe because this will be wrapped in JNI calls.

rillian commented 9 years ago

Hmm. I hadn't looked at this. It's mostly thread-safe I think, with everything descending from the entry point with local variables. I believe the underlying tiff, jpeg, png and z libraries are also thread-safe.

The problem is the error handling, which goes through the tiff2png_jmpbuf_struct global. You'd have to move that to a per-thread variable and pass it into tiff2png() instead.