Class SimpleReadWriteLock

    • Constructor Detail

      • SimpleReadWriteLock

        public SimpleReadWriteLock()
        Default constructor creating a default ReentrantReadWriteLock
      • SimpleReadWriteLock

        public SimpleReadWriteLock​(boolean bFair)
        Constructor creating a ReentrantReadWriteLock with the provided fairness
        Parameters:
        bFair - true if this lock should use a fair ordering policy
    • Method Detail

      • readLockedGet

        public <T> T readLockedGet​(@Nonnull
                                   Supplier<? extends T> aSupplier)
        Execute the provided callable in a read lock. Note: no nullable/non-nullable can be assumed.
        Type Parameters:
        T - Return type
        Parameters:
        aSupplier - Callable to be executed. May not be null.
        Returns:
        The return value of the callable. May be null.
      • readLocked

        public void readLocked​(@Nonnull
                               Runnable aRunnable)
        Execute the provided runnable in a read lock.
        Parameters:
        aRunnable - Runnable to be executed. May not be null.
      • readLockedThrowing

        public <EXTYPE extends Exception> void readLockedThrowing​(@Nonnull
                                                                  IThrowingRunnable<EXTYPE> aRunnable)
                                                           throws EXTYPE extends Exception
        Execute the provided runnable in a read lock.
        Type Parameters:
        EXTYPE - Exception type to be thrown
        Parameters:
        aRunnable - Runnable to be executed. May not be null.
        Throws:
        EXTYPE - If the callable throws the exception
        EXTYPE extends Exception
      • readLockedGetThrowing

        public <T,​EXTYPE extends Exception> T readLockedGetThrowing​(@Nonnull
                                                                          IThrowingSupplier<? extends T,​EXTYPE> aCallable)
                                                                   throws EXTYPE extends Exception
        Execute the provided callable in a read lock. Note: no nullable/non-nullable can be assumed.
        Type Parameters:
        T - Return type
        EXTYPE - Exception type to be thrown
        Parameters:
        aCallable - Callable to be executed. May not be null.
        Returns:
        The return value of the callable. May be null.
        Throws:
        EXTYPE - If the callable throws the exception
        EXTYPE extends Exception
      • readLockedBoolean

        public boolean readLockedBoolean​(@Nonnull
                                         BooleanSupplier aSupplier)
        Execute the provided callable in a read lock.
        Parameters:
        aSupplier - Callable to be executed. May not be null.
        Returns:
        The return value of the callable. May be null.
      • readLockedDouble

        public double readLockedDouble​(@Nonnull
                                       DoubleSupplier aSupplier)
        Execute the provided callable in a read lock.
        Parameters:
        aSupplier - Callable to be executed. May not be null.
        Returns:
        The return value of the callable. May be null.
      • readLockedInt

        public int readLockedInt​(@Nonnull
                                 IntSupplier aSupplier)
        Execute the provided callable in a read lock.
        Parameters:
        aSupplier - Callable to be executed. May not be null.
        Returns:
        The return value of the callable. May be null.
      • readLockedLong

        public long readLockedLong​(@Nonnull
                                   LongSupplier aSupplier)
        Execute the provided callable in a read lock.
        Parameters:
        aSupplier - Callable to be executed. May not be null.
        Returns:
        The return value of the callable. May be null.
      • writeLocked

        public void writeLocked​(@Nonnull
                                Runnable aRunnable)
        Execute the provided runnable in a write lock.
        Parameters:
        aRunnable - Runnable to be executed. May not be null.
      • writeLockedThrowing

        public <EXTYPE extends Exception> void writeLockedThrowing​(@Nonnull
                                                                   IThrowingRunnable<EXTYPE> aRunnable)
                                                            throws EXTYPE extends Exception
        Execute the provided runnable in a write lock.
        Type Parameters:
        EXTYPE - Exception type to be thrown
        Parameters:
        aRunnable - Runnable to be executed. May not be null.
        Throws:
        EXTYPE - If the runnable throws the exception
        EXTYPE extends Exception
      • writeLockedGet

        public <T> T writeLockedGet​(@Nonnull
                                    Supplier<? extends T> aSupplier)
        Execute the provided callable in a write lock. Note: no nullable/non-nullable can be assumed.
        Type Parameters:
        T - Return type
        Parameters:
        aSupplier - Callable to be executed. May not be null.
        Returns:
        The return value of the callable. May be null.
      • writeLockedGetThrowing

        public <T,​EXTYPE extends Exception> T writeLockedGetThrowing​(@Nonnull
                                                                           IThrowingSupplier<? extends T,​EXTYPE> aCallable)
                                                                    throws EXTYPE extends Exception
        Execute the provided callable in a write lock. Note: no nullable/non-nullable can be assumed.
        Type Parameters:
        T - Return type
        EXTYPE - Exception type to be thrown
        Parameters:
        aCallable - Callable to be executed. May not be null.
        Returns:
        The return value of the callable. May be null.
        Throws:
        EXTYPE - If the callable throws the exception
        EXTYPE extends Exception
      • writeLockedBoolean

        public boolean writeLockedBoolean​(@Nonnull
                                          BooleanSupplier aSupplier)
        Execute the provided callable in a write lock.
        Parameters:
        aSupplier - Callable to be executed. May not be null.
        Returns:
        The return value of the callable. May be null.
      • writeLockedDouble

        public double writeLockedDouble​(@Nonnull
                                        DoubleSupplier aSupplier)
        Execute the provided callable in a write lock.
        Parameters:
        aSupplier - Callable to be executed. May not be null.
        Returns:
        The return value of the callable. May be null.
      • writeLockedInt

        public int writeLockedInt​(@Nonnull
                                  IntSupplier aSupplier)
        Execute the provided callable in a write lock.
        Parameters:
        aSupplier - Callable to be executed. May not be null.
        Returns:
        The return value of the callable. May be null.
      • writeLockedLong

        public long writeLockedLong​(@Nonnull
                                    LongSupplier aSupplier)
        Execute the provided callable in a write lock.
        Parameters:
        aSupplier - Callable to be executed. May not be null.
        Returns:
        The return value of the callable. May be null.