Class SimpleLock

    • Constructor Detail

      • SimpleLock

        public SimpleLock()
        Default constructor creating a default ReentrantLock
      • SimpleLock

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

      • locked

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

        public <EXTYPE extends Exception> void lockedThrowing​(@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
      • lockedGet

        public <T> T lockedGet​(@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.
      • lockedGetThrowing

        public <T,​EXTYPE extends Exception> T lockedGetThrowing​(@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
      • lockedBoolean

        public boolean lockedBoolean​(@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.
      • lockedDouble

        public double lockedDouble​(@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.
      • lockedInt

        public int lockedInt​(@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.
      • lockedLong

        public long lockedLong​(@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.