[Proj] libproj4 thread safety

Patrick Mézard pmezard at gmail.com
Wed Feb 23 12:38:26 EST 2005


> > 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.

Great, I pick the good one then :-). Anyway, besides pj_errno, my
first impressions about the code thread-safety was really optimistic.

> > (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.

I second that. It is not the best solution, but for now only 2 lines
of code have to be edited.

> > 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.

Ok, I will definitely take a look at the code.

Thank you for your answer.

Patrick Mézard



More information about the Proj mailing list