diff options
author | Rich Hickey <richhickey@gmail.com> | 2007-07-09 14:40:28 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2007-07-09 14:40:28 +0000 |
commit | 08df868c33388c2e045f567b44d083a81935ef61 (patch) | |
tree | 90cafc82a178adeabe170a1cc184378366aef21e | |
parent | 06be2c38f892fa63a4b53a6700a09e19c6345c54 (diff) |
fixed so refs themselves have value semantics
-rw-r--r-- | src/jvm/clojure/lang/TRef.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/jvm/clojure/lang/TRef.java b/src/jvm/clojure/lang/TRef.java index b813eb5f..7adccaa1 100644 --- a/src/jvm/clojure/lang/TRef.java +++ b/src/jvm/clojure/lang/TRef.java @@ -19,6 +19,7 @@ public class TRef<T> extends AFn{ final AtomicReference<TVal> tvals; final AtomicReference<InheritableThreadLocal> dvals; + public TRef(){ this.tvals = new AtomicReference<TVal>(); this.dvals = new AtomicReference<InheritableThreadLocal>(); @@ -29,6 +30,19 @@ public TRef(T initVal){ tvals.set(new TVal(initVal, Transaction.ZERO_POINT, null)); } +public boolean equals(Object o){ + if(this == o) return true; + if(o == null || TRef.class != o.getClass()) return false; + + TRef other = (TRef) o; + + return dvals == other.dvals && tvals == other.tvals; +} + +public int hashCode(){ + return RT.hashCombine(dvals.hashCode(), tvals.hashCode()); +} + public T currentVal(){ Binding b = getThreadBinding(); if(b != null) |