GraphLib icon indicating copy to clipboard operation
GraphLib copied to clipboard

The Simple BlockGraph Implementation is not Thread Safe

Open Kneelawk opened this issue 3 years ago • 2 comments

The Issue

Currently, accessing and mutating a block graph from multiple threads is likely to cause a ConcurrentModificationException or just give inconsistent data. The SimpleBlockGraph, SimpleBlockGraphController, and UnloadingRegionBasedStorage all expect to be used from a single thread only.

Potential Fix

It would likely not be too hard to add in some synchronization primitives, to allow for efficient use from multiple threads. This may be something like a RWLock for each internal collection.

Kneelawk avatar Oct 09 '22 21:10 Kneelawk

This is actually looking a lot more complicated now that I'm looking into it. I might have to abandon making this thread safe.

Kneelawk avatar Oct 10 '22 00:10 Kneelawk

This is causing issues with Very Many Players and likely also C2ME: https://gist.github.com/sleepy-evelyn/225486485b09e328ce1e09be1146f9b1

These mods are essential now to maintaining a fast server running on Fabric.

sleepy-evelyn avatar May 24 '25 03:05 sleepy-evelyn