2017.03.01 17:05 "[Tiff] Using libtiff in a multi-threaded context", by Dinesh Iyer

2017.03.01 17:38 "Re: [Tiff] Using libtiff in a multi-threaded context", by Bob Friesenhahn

I am developing an application to read TIFF files using libtiff and I am using multi-threading to improve performance. I was wondering if I can do query operations such as TIFFComputeTile/TIFFComputeTile/TIFFgetfield at the same time that I am calling TIFFReadEncodedStrip on a different thread.

Libtiff does not do any locking internally. It would be ideal if libtiff is thread safe when using a thread per libtiff handle but there are a few known issues such as related to error reporting.

My other option is to "pause" the thread that is reading image data when a query such as that mentioned above is received.

It is not safe to access a libtiff handle from more than one thread at once because the handle is stateful and it may be necessary to access the file (possibly requiring a non-atomic seek plus read/write). I think that it is mostly safe if external locking assures that only one libtiff function is invoked at once on the same handle.

Bob
--
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/