[gdal-dev] Multithreading with OGR

Frank Warmerdam warmerdam at pobox.com
Fri Jun 25 12:39:02 EDT 2010


Martin Dobias wrote:
> On Fri, Jun 25, 2010 at 5:55 PM, Frank Warmerdam <warmerdam at pobox.com> wrote:
>>> My intent is to use two OGRLayer instances of the same layer: one
>>> instance for handling various stuff in main thread, the other one in
>>> worker thread for rendering. Can I expect the GetNextFeature calls to
>>> be reentrant, i.e. can they be called from both threads simultaneously
>>> using different instances of layers?
>> Martin,
>>
>> Are the different OGRLayer instances coming from distinct OGRDataSource
>> instances? If so, yes, you could normally treat them as reentrant though
>> there might be a few special cases where that turns out not to be true.
>> Certainly this is only a good idea in read-only activities.
> 
> Yes, I consider using distinct OGRDataSource instances for the
> OGRLayer instances. Could you please elaborate on the special cases
> you are referring to?

Martin,

Well, it is possible that some drivers use global static variables for
something or have other reentrancy issues.  It is difficult to be certain
without review in detail.  But generally speaking things should be fine.

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 gdal-dev mailing list