diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index 9738ab8..b3faaf3 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -2103,10 +2103,10 @@ the value that was swapped in." {:added "1.0" :static true} - ([^clojure.lang.Atom atom f] (.swap atom f)) - ([^clojure.lang.Atom atom f x] (.swap atom f x)) - ([^clojure.lang.Atom atom f x y] (.swap atom f x y)) - ([^clojure.lang.Atom atom f x y & args] (.swap atom f x y args))) + ([^clojure.lang.IAtom atom f] (.swap atom f)) + ([^clojure.lang.IAtom atom f x] (.swap atom f x)) + ([^clojure.lang.IAtom atom f x y] (.swap atom f x y)) + ([^clojure.lang.IAtom atom f x y & args] (.swap atom f x y args))) (defn compare-and-set! "Atomically sets the value of atom to newval if and only if the @@ -2114,14 +2114,14 @@ set happened, else false" {:added "1.0" :static true} - [^clojure.lang.Atom atom oldval newval] (.compareAndSet atom oldval newval)) + [^clojure.lang.IAtom atom oldval newval] (.compareAndSet atom oldval newval)) (defn reset! "Sets the value of atom to newval without regard for the current value. Returns newval." {:added "1.0" :static true} - [^clojure.lang.Atom atom newval] (.reset atom newval)) + [^clojure.lang.IAtom atom newval] (.reset atom newval)) (defn set-validator! "Sets the validator-fn for a var/ref/agent/atom. validator-fn must be nil or a diff --git a/src/jvm/clojure/lang/Atom.java b/src/jvm/clojure/lang/Atom.java index 5033d13..a964c49 100644 --- a/src/jvm/clojure/lang/Atom.java +++ b/src/jvm/clojure/lang/Atom.java @@ -14,7 +14,7 @@ package clojure.lang; import java.util.concurrent.atomic.AtomicReference; -final public class Atom extends ARef{ +final public class Atom extends ARef implements IAtom{ final AtomicReference state; public Atom(Object state){ diff --git a/src/jvm/clojure/lang/IAtom.java b/src/jvm/clojure/lang/IAtom.java new file mode 100644 index 0000000..74908f0 --- /dev/null +++ b/src/jvm/clojure/lang/IAtom.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) Rich Hickey. All rights reserved. + * The use and distribution terms for this software are covered by the + * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) + * which can be found in the file epl-v10.html 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. + **/ + +/* rich Aug 2, 2009 */ + +package clojure.lang; + +public interface IAtom{ +Object swap(IFn f); + +Object swap(IFn f, Object arg); + +Object swap(IFn f, Object arg1, Object arg2); + +Object swap(IFn f, Object x, Object y, ISeq args); + +boolean compareAndSet(Object oldv, Object newv); + +Object reset(Object newval); +}