Class StripedLock

    • Method Detail

      • lockAll

        public QuietAutoCloseable lockAll()
        Locks access to all stripes. No other thread may execute when this lock is held.
        Returns:
        A quiet auto-closeable that releases the lock when closed.
      • lockMultiple

        public QuietAutoCloseable lockMultiple​(Object... stripes)
        Locks access to the given individual stripes. Multiple threads may execute with locks on different file stripes.
        Parameters:
        stripes - The stripes to lock.
        Returns:
        A quiet auto-closeable that releases the lock when closed.
      • lockMultiple

        public QuietAutoCloseable lockMultiple​(Iterable<?> stripes)
        Locks access to the given individual stripes. Multiple threads may execute with locks on different file stripes.
        Parameters:
        stripes - The stripes to lock.
        Returns:
        A quiet auto-closeable that releases the lock when closed.
      • lockSingle

        public QuietAutoCloseable lockSingle​(Object stripe)
        Locks access to a single stripe. Multiple threads may execute with a lock on different file keys.
        Parameters:
        stripe - The stripe to lock.
        Returns:
        A quiet auto-closeable that releases the lock when closed.
      • stripes

        public int stripes()
        Gets the number of stripes.
        Returns:
        The number of stripes.
      • weak

        public boolean weak()
        Gets whether weak lazy locks are used.
        Returns:
        Whether weak lazy locks are used.
      • lazyWeakStripedLock

        public static StripedLock lazyWeakStripedLock​(int stripes)
        Creates a new striped lock with the given number of stripes. The locks are created lazily when required and are released when not referenced anymore.
        Parameters:
        stripes - The number of stripes.
        Returns:
        The striped lock.
      • stripedLock

        public static StripedLock stripedLock​(int stripes)
        Creates a new striped lock with the given number of stripes. The locks are created eagerly and are not released at least until the striped lock is garbage collected.
        Parameters:
        stripes - The number of stripes.
        Returns:
        The striped lock.