diff options
Diffstat (limited to 'src/org')
| -rw-r--r-- | src/org/clojure/runtime/IObj.java | 16 | ||||
| -rw-r--r-- | src/org/clojure/runtime/Keyword.java | 4 | ||||
| -rw-r--r-- | src/org/clojure/runtime/Obj.java | 6 | ||||
| -rw-r--r-- | src/org/clojure/runtime/TObj.java | 36 |
4 files changed, 54 insertions, 8 deletions
diff --git a/src/org/clojure/runtime/IObj.java b/src/org/clojure/runtime/IObj.java index 8fddcfe3..e4284aba 100644 --- a/src/org/clojure/runtime/IObj.java +++ b/src/org/clojure/runtime/IObj.java @@ -1,3 +1,13 @@ +/**
+ * Copyright (c) Rich Hickey. All rights reserved.
+ * The use and distribution terms for this software are covered by the
+ * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
+ * which can be found in the file CPL.TXT at the root of this distribution.
+ * By using this software in any fashion, you are agreeing to be bound by
+ * the terms of this license.
+ * You must not remove this notice, or any other, from this software.
+ **/
+
package org.clojure.runtime;
/**
@@ -8,9 +18,9 @@ package org.clojure.runtime; * To change this template use File | Settings | File Templates.
*/
public interface IObj {
-Object put(Comparable key, Object val);
+Object put(ThreadLocalData tld, Comparable key, Object val) throws Exception;
-Object get(Comparable key);
+Object get(ThreadLocalData tld, Comparable key) throws Exception;
-boolean has(Comparable key);
+boolean has(ThreadLocalData tld, Comparable key) throws Exception;
}
diff --git a/src/org/clojure/runtime/Keyword.java b/src/org/clojure/runtime/Keyword.java index 161e0c88..63ea4d7d 100644 --- a/src/org/clojure/runtime/Keyword.java +++ b/src/org/clojure/runtime/Keyword.java @@ -44,7 +44,7 @@ public Object invoke(ThreadLocalData tld, Object obj) throws Exception { if (obj == null) return null; - return ((IObj)obj).get(this); + return ((IObj)obj).get(tld,this); } /** @@ -58,7 +58,7 @@ public Object invoke(ThreadLocalData tld, Object obj) throws Exception */ public Object invoke(ThreadLocalData tld, Object obj, Object val) throws Exception { - return ((IObj)obj).put(this,val); + return ((IObj)obj).put(tld,this,val); } public Object invoke(ThreadLocalData tld, Object arg1, Object arg2, Object arg3) throws Exception diff --git a/src/org/clojure/runtime/Obj.java b/src/org/clojure/runtime/Obj.java index ce71c736..c8aa532d 100644 --- a/src/org/clojure/runtime/Obj.java +++ b/src/org/clojure/runtime/Obj.java @@ -19,7 +19,7 @@ public class Obj implements IObj { IdentityHashMap attrs; public static final int INITIAL_SIZE = 7; -public Object put(Comparable key, Object val) +public Object put(ThreadLocalData tld, Comparable key, Object val) { if(attrs == null) attrs = new IdentityHashMap(INITIAL_SIZE); @@ -27,14 +27,14 @@ public Object put(Comparable key, Object val) return val; } -public Object get(Comparable key) +public Object get(ThreadLocalData tld, Comparable key) { if(attrs == null) return null; return attrs.get(key); } -public boolean has(Comparable key){ +public boolean has(ThreadLocalData tld, Comparable key){ if(attrs == null) return false; return attrs.containsKey(key); diff --git a/src/org/clojure/runtime/TObj.java b/src/org/clojure/runtime/TObj.java new file mode 100644 index 00000000..8a0acb57 --- /dev/null +++ b/src/org/clojure/runtime/TObj.java @@ -0,0 +1,36 @@ +/**
+ * Copyright (c) Rich Hickey. All rights reserved.
+ * The use and distribution terms for this software are covered by the
+ * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
+ * which can be found in the file CPL.TXT at the root of this distribution.
+ * By using this software in any fashion, you are agreeing to be bound by
+ * the terms of this license.
+ * You must not remove this notice, or any other, from this software.
+ **/
+
+package org.clojure.runtime;
+
+public class TObj implements IObj{
+TRef attrs;
+
+public TObj(ThreadLocalData tld) throws Exception{
+ this.attrs = Transaction.tref(tld,new RBTree());
+}
+
+public Object put(ThreadLocalData tld, Comparable key, Object val) throws Exception {
+ RBTree t = (RBTree) Transaction.get(tld, attrs);
+ t = t.put(key, val);
+ Transaction.set(tld,attrs,t);
+ return val;
+}
+
+public Object get(ThreadLocalData tld, Comparable key) throws Exception {
+ RBTree t = (RBTree) Transaction.get(tld, attrs);
+ return t.get(key);
+}
+
+public boolean has(ThreadLocalData tld, Comparable key) throws Exception {
+ RBTree t = (RBTree) Transaction.get(tld, attrs);
+ return t.contains(key);
+}
+}
|
