aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/source/lux.lux10
-rw-r--r--stdlib/source/lux/concurrency/atom.lux20
-rw-r--r--stdlib/source/lux/concurrency/stm.lux1
3 files changed, 12 insertions, 19 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index 01064b829..7ae8c2847 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -1,7 +1,7 @@
## Basic types
(_lux_def Bool
(+12 ["lux" "Bool"]
- (+0 "java.lang.Boolean" (+0)))
+ (+0 "#Bool" (+0)))
(+1 [["lux" "type?"] (+0 true)]
(+1 [["lux" "export?"] (+0 true)]
(+1 [["lux" "doc"] (+6 "Your standard, run-of-the-mill boolean values.")]
@@ -19,7 +19,7 @@
(_lux_def Int
(+12 ["lux" "Int"]
- (+0 "java.lang.Long" (+0)))
+ (+0 "#Int" (+0)))
(+1 [["lux" "type?"] (+0 true)]
(+1 [["lux" "export?"] (+0 true)]
(+1 [["lux" "doc"] (+6 "Your standard, run-of-the-mill integer numbers.")]
@@ -27,7 +27,7 @@
(_lux_def Real
(+12 ["lux" "Real"]
- (+0 "java.lang.Double" (+0)))
+ (+0 "#Real" (+0)))
(+1 [["lux" "type?"] (+0 true)]
(+1 [["lux" "export?"] (+0 true)]
(+1 [["lux" "doc"] (+6 "Your standard, run-of-the-mill floating-point numbers.")]
@@ -45,7 +45,7 @@
(_lux_def Char
(+12 ["lux" "Char"]
- (+0 "java.lang.Character" (+0)))
+ (+0 "#Char" (+0)))
(+1 [["lux" "type?"] (+0 true)]
(+1 [["lux" "export?"] (+0 true)]
(+1 [["lux" "doc"] (+6 "Your standard, run-of-the-mill character values.")]
@@ -53,7 +53,7 @@
(_lux_def Text
(+12 ["lux" "Text"]
- (+0 "java.lang.String" (+0)))
+ (+0 "#Text" (+0)))
(+1 [["lux" "type?"] (+0 true)]
(+1 [["lux" "export?"] (+0 true)]
(+1 [["lux" "doc"] (+6 "Your standard, run-of-the-mill string values.")]
diff --git a/stdlib/source/lux/concurrency/atom.lux b/stdlib/source/lux/concurrency/atom.lux
index 09dd642ed..f2ec8b46c 100644
--- a/stdlib/source/lux/concurrency/atom.lux
+++ b/stdlib/source/lux/concurrency/atom.lux
@@ -1,31 +1,25 @@
(;module:
lux
- (lux [io #- run]
- host))
-
-(jvm-import (java.util.concurrent.atomic.AtomicReference V)
- (new [V])
- (compareAndSet [V V] boolean)
- (get [] V))
+ (lux [io #- run]))
(type: #export (Atom a)
{#;doc "Atomic references that are safe to mutate concurrently."}
- (AtomicReference a))
+ (#;HostT "#Atom" (#;Cons a #;Nil)))
(def: #export (atom value)
(All [a] (-> a (Atom a)))
- (AtomicReference.new [value]))
+ (_lux_proc ["atom" "new"] [value]))
(def: #export (get atom)
(All [a] (-> (Atom a) (IO a)))
- (io (AtomicReference.get [] atom)))
+ (io (_lux_proc ["atom" "get"] [atom])))
(def: #export (compare-and-swap current new atom)
{#;doc "Only mutates an atom if you can present it's current value.
That guarantees that atom wasn't updated since you last read from it."}
(All [a] (-> a a (Atom a) (IO Bool)))
- (io (AtomicReference.compareAndSet [current new] atom)))
+ (io (_lux_proc ["atom" "compare-and-swap"] [atom current new])))
(def: #export (update f atom)
{#;doc "Updates an atom by applying a function to its current value.
@@ -34,8 +28,8 @@
The retries will be done with the new values of the atom, as they show up."}
(All [a] (-> (-> a a) (Atom a) (IO Unit)))
- (io (let [old (AtomicReference.get [] atom)]
- (if (AtomicReference.compareAndSet [old (f old)] atom)
+ (io (let [old (_lux_proc ["atom" "get"] [atom])]
+ (if (_lux_proc ["atom" "compare-and-swap"] [atom old (f old)])
[]
(io;run (update f atom))))))
diff --git a/stdlib/source/lux/concurrency/stm.lux b/stdlib/source/lux/concurrency/stm.lux
index 36eb6854e..c1c3153dd 100644
--- a/stdlib/source/lux/concurrency/stm.lux
+++ b/stdlib/source/lux/concurrency/stm.lux
@@ -12,7 +12,6 @@
maybe
[number "Nat/" Codec<Text,Nat>]
text/format)
- host
[compiler]
(macro [ast]
["s" syntax #+ syntax: Syntax])