guava icon indicating copy to clipboard operation
guava copied to clipboard

Add possibility to create Striped lock with 'fair ordering policy' = true

Open armsargis opened this issue 8 years ago • 11 comments

I would like to use Striped with fair=true, I checked code and seems in current 19.0 version there is no way to do it.

armsargis avatar Jun 29 '16 10:06 armsargis

I second this request. Maybe it would be good enough to just make the method

com.google.common.util.concurrent.Striped.lazy(int, Supplier<L>)

(and similar methods) public. Right now we are invoking that method via reflection to supply fair locks.

DerEineDa avatar Aug 22 '16 09:08 DerEineDa

this ticket is still open?

igorKryvenko avatar Jul 24 '17 21:07 igorKryvenko

Now that Guava gets released at a much shorter interval, I hope this ticket can be considered again :) In other words: Bump!

ChristianCiach avatar Oct 18 '17 08:10 ChristianCiach

+1 for fairness.

j-white avatar Jan 26 '18 21:01 j-white

Any update on this? It would be really useful to have fair locking

Felk avatar Jul 24 '18 16:07 Felk

I put this on our agenda to discuss on Thursday.

cpovirk avatar Jul 31 '18 20:07 cpovirk

We're going to add something that can be used for this (by adding Striped.custom, similar to https://github.com/google/guava/issues/1893 (though that requested lazyWeakCustom, which we aren't doing until we have a chance to look more into the lazy-weak use case)). We have another thing to add, too (Striped.intrinsicMonitors), but I'll try not to let this sit too much longer.

cpovirk avatar Aug 02 '18 19:08 cpovirk

Is it possible to bump this? I know the custom method exists now, but it's been package-private for an extended period of time. I'd love to use Striped, but the inability to use custom or even extend any of the sub-classes without having to resort to reflection is forcing me to implement my own.

Just for reference: https://github.com/google/guava/commit/d61375f7260e138e393822c2d1bda42a88419fc9#commitcomment-29941521

williamthompson-toast avatar Mar 06 '20 16:03 williamthompson-toast

This would come in handy for Bazel. Would a PR that makes Striped#custom public be welcome?

fmeum avatar Aug 23 '23 12:08 fmeum

+1 on either supporting lock fainess or making Striped#custom public.

duongkame avatar Sep 07 '23 22:09 duongkame

We're going to add something that can be used for this (by adding Striped.custom, similar to #1893 (though that requested lazyWeakCustom, which we aren't doing until we have a chance to look more into the lazy-weak use case)). We have another thing to add, too (Striped.intrinsicMonitors), but I'll try not to let this sit too much longer.

So, it's been sitting here for 5 years. Can we do anything to allow fairness?

duongkame avatar Sep 07 '23 23:09 duongkame