Class StripedExt


  • public class StripedExt
    extends Object
    Here we extend Striped to support creating fair reentrant locks. We use reflection to invoke 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/2514
    Author:
    jwhite
    • Constructor Detail

      • StripedExt

        public StripedExt()
    • Method Detail

      • fairLock

        public static com.google.common.util.concurrent.Striped<Lock> fairLock​(int stripes)
        Creates a Striped<Lock> with eagerly initialized, strongly referenced locks. Every lock is fair and reentrant.
        Parameters:
        stripes - the minimum number of stripes (locks) required
        Returns:
        a new Striped<Lock>