kotlinx.coroutines
kotlinx.coroutines copied to clipboard
CancellableQueueSynchronizer and ReadWriteMutex
Introduce SegmentQueueSynchronizer abstraction for synchronization primitives and ReadWriteMutex. Please follow the provided documentation and the test suite for details.
Here is a link to a successful nightly build with these changes: https://teamcity.jetbrains.com/buildConfiguration/KotlinTools_KotlinxCoroutines_NightlyStress/3009472
We should add a comment here once the PR is merged
It's important not to forget about #2401 when introducing RWMutex
Just out of curiosity, why did this die?
It seems well-written/documented (can't comment on the implementation)
There were unresolved questions about public API shape and how to expose read/write parts. We may return to it after #3103
We may return to it after #3103
That was merged earlier this year (congrats to all btw, big PR!). Has there been any internal progress on this since then?
@Tmpod we are evaluating this change on IDEA codebase. Could you please elaborate on your interest in this primitive? E.g. what use-cases are you aiming to solve with it?
Could you please elaborate on your interest in this primitive? E.g. what use-cases are you aiming to solve with it?
I am looking to improve the performance of some datastructures which are temporarily using just a single mutex both for reading and writing. Using a readers-writer lock seems like a good option.[1] I've seen a lot of other people, in issues and the likes, asking for this type of synchronization primitive as well.
I may end up writing my own primitive, based on code shared around here, for the time being, but having a high-quality implementation in the library would be really useful (though quite hard, I know!).
[1]: It should be noted that updating this datastructure cannot be done atomically since it's quite non-trivial.