Class StripedExt


  • public class StripedExt
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      StripedExt()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.google.common.util.concurrent.Striped<java.util.concurrent.locks.Lock> fairLock​(int stripes)
      Creates a Striped<Lock> with eagerly initialized, strongly referenced locks.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StripedExt

        public StripedExt()
    • Method Detail

      • fairLock

        public static com.google.common.util.concurrent.Striped<java.util.concurrent.locks.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>