VolatileNNLazyValue, AtomicNNLazyValue <: NNLazyValue

This commit is contained in:
peter
2010-07-31 10:13:49 +01:00
parent c6245b733c
commit 46b73abe54
3 changed files with 3 additions and 9 deletions
@@ -21,13 +21,10 @@ import org.jetbrains.annotations.NotNull;
/**
* @author peter
*/
public abstract class AtomicNotNullLazyValue<T> {
public abstract class AtomicNotNullLazyValue<T> extends NotNullLazyValue<T> {
private volatile T myValue;
@NotNull
protected abstract T compute();
@NotNull
public final T getValue() {
if (myValue != null) {
@@ -29,7 +29,7 @@ public abstract class NotNullLazyValue<T> {
protected abstract T compute();
@NotNull
public final T getValue() {
public T getValue() {
if (!myComputed) {
myValue = compute();
myComputed = true;
@@ -21,13 +21,10 @@ import org.jetbrains.annotations.NotNull;
/**
* @author peter
*/
public abstract class VolatileNotNullLazyValue<T> {
public abstract class VolatileNotNullLazyValue<T> extends NotNullLazyValue<T> {
private volatile T myValue;
@NotNull
protected abstract T compute();
@NotNull
public final T getValue() {
T value = myValue;