Is multi-threaded access to Graphhopper object safe using RAM_STORE?

If you’re using the Graphhopper object with data access type of RAM_STORE (so everything is loaded into memory), then after the call to load(graphHopper) can the Graphhopper object (and its contained loaded graphs) be accessed from multiple threads without the need for synchronisation? i.e. Is it and all other relevant objects thread-safe (and likely to remain thread-safe in the future)?

I understand if you’re using memory mapped or some other data access type it would not be thread safe, but once the graph is loaded entirely into RAM - which I’m assuming is completed entirely within Graphhopper.load(graphHopper) - I would have thought the Graphhopper object and its underlying graph objects would become effectively immutable? Is this the case?

Many thanks

Phil

For reading, yes. For writing: not yet.

There is SYNC_MMAP which makes mmapping thread safe. The Java API for mmaping makes it unsafe as the ‘mmap access pointer’ is a state of a mmapped ByteBuffer.

I would have thought the Graphhopper object and its underlying graph objects would become effectively immutable?

There is currently no code which would reject writing concurrently to one edge. And partly even that is thread safe e.g. when using int storage and writing some int flags or the distance, writing long flags or writing an int in a byte storage is not safe though and needs a bit synchronization.

Thanks Peter! That’s great.