1 19 package gcc.util; 20 21 25 public abstract class FutureObject 26 { 27 private static final boolean _volatileIsEffectiveMemoryBarrier = MemoryBarrier.USE_VOLATILE; 28 29 private volatile boolean _evaluated = false; 30 31 private Object _value; 32 33 37 public abstract Object evaluate(); 38 39 public final Object getValue() 40 { 41 if (_volatileIsEffectiveMemoryBarrier) 42 { 43 if (! _evaluated) 44 { 45 synchronized (this) 46 { 47 if (! _evaluated) 48 { 49 _value = evaluate(); 50 _evaluated = true; 51 } 52 } 53 } 54 } 55 else 56 { 57 synchronized (this) 58 { 59 if (! _evaluated) 60 { 61 _value = evaluate(); 62 _evaluated = true; 63 } 64 } 65 } 66 return _value; 67 } 68 } 69 | Popular Tags |