Package org.apache.spark.util
Class TransientBestEffortLazyVal<T>
Object
org.apache.spark.util.TransientBestEffortLazyVal<T>
- All Implemented Interfaces:
Serializable
A lock-free implementation of a lazily-initialized variable.
If there are concurrent initializations then the `compute()` function may be invoked
multiple times. However, only a single `compute()` result will be stored and all readers
will receive the same result object instance.
This may be helpful for avoiding deadlocks in certain scenarios where exactly-once
value computation is not a hard requirement.
The main difference between this and [[BestEffortLazyVal]] is that:
[[BestEffortLazyVal]] serializes the cached value after computation, while
[[TransientBestEffortLazyVal]] always serializes the compute function.
- See Also:
- Note:
- This helper class has additional requirements on the compute function: 1) The compute function MUST not return null; 2) The computation failure is not cached., Scala 3 uses a different implementation of lazy vals which doesn't have this problem. Please refer to Lazy Vals Initialization for more details.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
TransientBestEffortLazyVal
-
-
Method Details
-
apply
-