public class StripedExt extends Object
Striped
to support creating fair reentrant locks.
We use reflection to invoke com.google.common.util.concurrent.Striped.CompactStriped#CompactStriped(int, Supplier)
and provide a supplier that creates a fair lock.
This is clearly a hack, but seems better than the alternative of A) trying to find another library that supports this
or B) re-implementing striped locking ourselves.
Guava Feature Request:
https://github.com/google/guava/issues/2514Constructor and Description |
---|
StripedExt() |
Modifier and Type | Method and Description |
---|---|
static com.google.common.util.concurrent.Striped<Lock> |
fairLock(int stripes)
Creates a
Striped<Lock> with eagerly initialized, strongly referenced locks. |
public static com.google.common.util.concurrent.Striped<Lock> fairLock(int stripes)
Striped<Lock>
with eagerly initialized, strongly referenced locks.
Every lock is fair and reentrant.stripes
- the minimum number of stripes (locks) requiredStriped<Lock>
Copyright © 2021. All rights reserved.