<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Mika,</p>
<p><br>
</p>
<div class="moz-cite-prefix">Le 12/09/2024 à 09:22, Heiskanen Mika
(FMI) via gdal-dev a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:AS2PR09MB6367C0561A3BECB76875155CE1642@AS2PR09MB6367.eurprd09.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css" style="display:none;">P {margin-top:0;margin-bottom:0;}</style>
<ul
data-editing-info="{"orderedStyleType":1,"unorderedStyleType":4}"
style="margin-top: 0px; margin-bottom: 0px;">
<li
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); list-style-type: "➢ ";">
<div class="elementToProof">Ah, and one thing I realized is
that OGRSpatialReference isn't thread-safe, so I've also
added an optional SetThreadSafe() on it, to also use a
per-instance mutex in multi-threaded scenarios (cf commit
<a
href="https://github.com/OSGeo/gdal/pull/10746/commits/c7e1862273dd018e58a01f25b21fdff6dbfdd1cd"
id="LPlnk912365" class="OWAAutoLink moz-txt-link-freetext"
moz-do-not-send="true">
https://github.com/OSGeo/gdal/pull/10746/commits/c7e1862273dd018e58a01f25b21fdff6dbfdd1cd</a>).</div>
</li>
</ul>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Perhaps I am missing something, but why not use read locks for
const methods and write locks for non-const methods so that
readers would not block each other so much?</div>
</blockquote>
<p>Read locks might not be sufficient for getters to run safely,
because there's often mutable state behind. For example if someone
uses WKT node manipulation functions like SetNode(), this modifies
the OGRSpatialRefernce internal WKT tree, and a flag is set to
track that. The next time a getter is called, and that getter
needs to call a PROJ method to get the information, it first
reconstruct a WKT string from the WKT tree, makes PROJ re-ingest
it to update its PJ* internal model, and then call the PROJ
getter. Some PROJ getters also use internal mutable state.<br>
</p>
<p>At this stage, using a full mutex is definitely a much safer
option. I don't also expect calls to OGRSpatialReference methods
to be bottlenecks in typical multi-threaded usages.</p>
<p><br>
</p>
<p>Even</p>
<span style="white-space: pre-wrap">
</span>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>