[gdal-dev] Thread safety of RasterIO

Even Rouault even.rouault at spatialys.com
Sat Oct 3 09:50:22 PDT 2020


Hi,

> I am trying to add an async interface to node-gdal (the Node.js bindings
> for GDAL) and I can't find any official statement on the library's
> thread safety.

The default for standard C/C++ libraries: you can't use any object/handle concurrently from 
multiple threads, unless it is explicitly mentionned to be safe.

> There is an old FAQ on the trac server which states that
> one should not access the same GDALDataset from multiple threads but it
> has a section about GDAL 1.5 and another one about GDAL 2.x, so I guess
> that it is not really up to date.

Most of what applies to GDAL 2 should still apply in this respect.

> 
> There is also the RFC 47 that mentions a static global mutex (impacting
> the performance) which makes me think that synchronization is already
> taken care of?

RFC 47 was never adopted/implemented. I've modified its title to make it more obvious.

> 
> Am I safe calling RasterIO on the same dataset from multiple threads?

No, you aren't.

> Are there some operations that work and others that do not? From what I
> have encountered so far, simple reading seems to work for me.

You have been just lucky. It could just crash with other drivers, other situations.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20201003/45bbb91b/attachment.html>


More information about the gdal-dev mailing list