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

Created on 29 Jun 2016  路  8Comments  路  Source: google/guava

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.

P3 package=concurrent type=addition

Most helpful comment

I put this on our agenda to discuss on Thursday.

All 8 comments

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.

this ticket is still open?

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

+1 for fairness.

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

I put this on our agenda to discuss on Thursday.

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.

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

Was this page helpful?
0 / 5 - 0 ratings