Class ConcurrentLazy<V,​T extends Exception>

  • Type Parameters:
    V - the type of the value the task will evaluate to.
    T - the type of exception that the task may throw.
    All Implemented Interfaces:
    Callable<V>, CallableEx<V,​T>

    public final class ConcurrentLazy<V,​T extends Exception>
    extends Object
    implements CallableEx<V,​T>

    A concurrent version of Lazy which uses a lock-free CAS (as opposed to DCL).

    Since:
    2017.2
    Author:
    Andrey Shcheglov <mailto:andrey.shcheglov@jetbrains.com>
    See Also:
    Lazy
    • Method Detail

      • from

        @NotNull
        public static <V> ConcurrentLazy<V,​Exception> from​(@NotNull
                                                                 Callable<V> callable)

        Creates a new lazy value from the specified task.

        Type Parameters:
        V - the type of the value the task will evaluate to.
        Parameters:
        callable - the task to be executed (once, in the best case).
        Returns:
        the newly-created lazy value.
        See Also:
        from(CallableEx, Class)
      • from

        @NotNull
        public static <V,​T extends ExceptionConcurrentLazy<V,​T> from​(@NotNull
                                                                                   CallableEx<V,​T> callable,
                                                                                   @NotNull
                                                                                   Class<T> exceptionType)

        Creates a new lazy value from the specified task.

        Type Parameters:
        V - the type of the value the task will evaluate to.
        T - the type of exception that the task may throw.
        Parameters:
        callable - the task to be executed (once, in the best case).
        exceptionType - the type of exception that the task may throw.
        Returns:
        the newly-created lazy value.
        See Also:
        from(Callable)
      • call

        public V call()
               throws T extends Exception
        Specified by:
        call in interface Callable<V>
        Specified by:
        call in interface CallableEx<V,​T extends Exception>
        Throws:
        Error - if thrown by the underlying callable task.
        RuntimeException - if thrown by the underlying callable task, or the task throws a checked exception other than T, or the task is interrupted (in this last case, it's the client's responsibility to process the cause of the exception).
        T - if unable to compute a result.
        T extends Exception
        See Also:
        CallableEx.call()