File tree Expand file tree Collapse file tree 3 files changed +34
-7
lines changed Expand file tree Collapse file tree 3 files changed +34
-7
lines changed Original file line number Diff line number Diff line change 22312231 the value that was swapped in."
22322232 {:added " 1.0"
22332233 :static true }
2234- ([^clojure.lang.Atom atom f] (.swap atom f))
2235- ([^clojure.lang.Atom atom f x] (.swap atom f x))
2236- ([^clojure.lang.Atom atom f x y] (.swap atom f x y))
2237- ([^clojure.lang.Atom atom f x y & args] (.swap atom f x y args)))
2234+ ([^clojure.lang.IAtom atom f] (.swap atom f))
2235+ ([^clojure.lang.IAtom atom f x] (.swap atom f x))
2236+ ([^clojure.lang.IAtom atom f x y] (.swap atom f x y))
2237+ ([^clojure.lang.IAtom atom f x y & args] (.swap atom f x y args)))
22382238
22392239(defn compare-and-set!
22402240 " Atomically sets the value of atom to newval if and only if the
22412241 current value of the atom is identical to oldval. Returns true if
22422242 set happened, else false"
22432243 {:added " 1.0"
22442244 :static true }
2245- [^clojure.lang.Atom atom oldval newval] (.compareAndSet atom oldval newval))
2245+ [^clojure.lang.IAtom atom oldval newval] (.compareAndSet atom oldval newval))
22462246
22472247(defn reset!
22482248 " Sets the value of atom to newval without regard for the
22492249 current value. Returns newval."
22502250 {:added " 1.0"
22512251 :static true }
2252- [^clojure.lang.Atom atom newval] (.reset atom newval))
2252+ [^clojure.lang.IAtom atom newval] (.reset atom newval))
22532253
22542254(defn set-validator!
22552255 " Sets the validator-fn for a var/ref/agent/atom. validator-fn must be nil or a
Original file line number Diff line number Diff line change 1414
1515import java .util .concurrent .atomic .AtomicReference ;
1616
17- final public class Atom extends ARef {
17+ final public class Atom extends ARef implements IAtom {
1818final AtomicReference state ;
1919
2020public Atom (Object state ){
Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright (c) Rich Hickey. All rights reserved.
3+ * The use and distribution terms for this software are covered by the
4+ * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
5+ * which can be found in the file epl-v10.html at the root of this distribution.
6+ * By using this software in any fashion, you are agreeing to be bound by
7+ * the terms of this license.
8+ * You must not remove this notice, or any other, from this software.
9+ **/
10+
11+ /* rich Aug 2, 2009 */
12+
13+ package clojure .lang ;
14+
15+ public interface IAtom {
16+ Object swap (IFn f );
17+
18+ Object swap (IFn f , Object arg );
19+
20+ Object swap (IFn f , Object arg1 , Object arg2 );
21+
22+ Object swap (IFn f , Object x , Object y , ISeq args );
23+
24+ boolean compareAndSet (Object oldv , Object newv );
25+
26+ Object reset (Object newval );
27+ }
You can’t perform that action at this time.
0 commit comments