[Proj] libproj4 thread safety

Frank Warmerdam fwarmerdam at gmail.com
Wed Feb 23 11:56:19 EST 2005


On Wed, 23 Feb 2005 10:25:18 +0100, Patrick Mézard <pmezard at gmail.com> wrote:
> [This message is mostly about libproj4. If the PROJ.4 mailing list is
> not the right place to post, please redirect me to a more suitable
> location]

Patrick,

This is a great place for libproj4 questions, though it is helpful for
specific questions to clarify whether you are referrning to Gerald's
current libproj4, or the PROJ.4 libs from remotesensing.org. 


> Could I assume that pj_errno is the only libproj4 part which is not
> threadsafe ? 

It is the only part of libproj4 that is not thread-safe as far as I know.
The remotesensing.org proj.4 has other issues in the grid shifting
code for instance. 

> (not that I'd be glad to live with that, but it could be
> corrected). Is anybody interested in having regular -thread safe-
> return codes instead (or in plus of the global variable) ? Do you
> think it can be done with a small amount of work, while leaving the
> current interface unchanged (apart from adding return values to "void"
> functions or adding new functions with new prototypes) ?

I don't particularly think adding error returns to everything is a
prudent approach.  Instead I would suggest making pj_errno thread
local as an option. 
 
> 2- Are the opaque structures returned by pj_init thread-safe, that is,
> are they "const" in a C++ sense ? Or should I create one per thread ?

In theory it should be safe to share them between threads.

But because PROJ.4 has not been extensively used or reviewed
for multi-threaded applications I think there is a non-trivial risk that
there are subtle issues in there that are not immediately obvious.

At least by starting with libproj4, instead of the remotesensing.org
PROJ.4 you have a simpler base since libproj4 is pretty well 
focused on the reprojection operation itself as opposed to all the
other cruft in the other library. 

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the Proj mailing list