kotlinx.coroutines icon indicating copy to clipboard operation
kotlinx.coroutines copied to clipboard

CancellableQueueSynchronizer and ReadWriteMutex

Open ndkoval opened this issue 5 years ago • 8 comments

Introduce SegmentQueueSynchronizer abstraction for synchronization primitives and ReadWriteMutex. Please follow the provided documentation and the test suite for details.

ndkoval avatar May 21 '20 15:05 ndkoval

Here is a link to a successful nightly build with these changes: https://teamcity.jetbrains.com/buildConfiguration/KotlinTools_KotlinxCoroutines_NightlyStress/3009472

ndkoval avatar Jul 06 '20 00:07 ndkoval

We should add a comment here once the PR is merged

ndkoval avatar Dec 21 '20 22:12 ndkoval

It's important not to forget about #2401 when introducing RWMutex

ndkoval avatar Sep 30 '21 14:09 ndkoval

Just out of curiosity, why did this die?

It seems well-written/documented (can't comment on the implementation)

GavinRay97 avatar Sep 10 '22 17:09 GavinRay97

There were unresolved questions about public API shape and how to expose read/write parts. We may return to it after #3103

qwwdfsad avatar Sep 12 '22 08:09 qwwdfsad

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 avatar Nov 24 '23 09:11 Tmpod

@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?

qwwdfsad avatar Nov 24 '23 10:11 qwwdfsad

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.

Tmpod avatar Nov 25 '23 12:11 Tmpod