
Thread
2017.03.01 18:33 "Re: [Tiff] Using libtiff in a multi-threaded context", by Roger Leigh
On 01/03/2017 17:05, Dinesh Iyer wrote:
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.
See https://github.com/ome/ome-files-cpp/blob/master/lib/ome/files/tiff/Sentry.cpp for my approach to tackling this.
- RAII sentry object to save and restore libtiff state, including error handlers
- uses a recursive mutex so you can call functions which also create their own sentries and lock the mutex
- traps libtiff errors and throws as exceptions
- Note: I've not done any serious multi-threaded performance testing. My primary goal was safe error handling. Might be useful for inspiration. Or feel free to copy (it's BSD licensed).