How to implement an efficient Readers-Writer lock?

You wouldn’t want to use locks for OS native threads. You’d need to yield to Julia scheduler and not to OS while waiting.

I don’t think it’d be hard to implement a simple reader-writer lock based on Threads.Condition. Maybe look at The Art of Multiprocessor Programming - 2nd Edition or An Error Occurred Setting Your User Cookie

You can also create a reader-writer lock from multiple channels, although it is rather a mental exercise than a useful implementation: Locks · Reagents (It should be a totally valid one, though)

2 Likes