aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/control/concurrency/process.lux
diff options
context:
space:
mode:
authorEduardo Julian2020-07-11 19:23:29 -0400
committerEduardo Julian2020-07-11 19:23:29 -0400
commit6346bc55f8b62b48253369fa1f28b93d6500e885 (patch)
treec286664d4b3571736fe9f8fe0ee11271a05273a0 /stdlib/source/lux/control/concurrency/process.lux
parentd48c3ff75f23a62c7f13ff411c25073e618b19de (diff)
Got the JS compiler to compile fully.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/control/concurrency/process.lux51
1 files changed, 25 insertions, 26 deletions
diff --git a/stdlib/source/lux/control/concurrency/process.lux b/stdlib/source/lux/control/concurrency/process.lux
index 3b273753a..dd38e3041 100644
--- a/stdlib/source/lux/control/concurrency/process.lux
+++ b/stdlib/source/lux/control/concurrency/process.lux
@@ -117,7 +117,7 @@
[_ (atom.update (|>> (#.Cons {#creation (.nat ("lux io current-time"))
#delay milli-seconds
#action action}))
- runner)]
+ ..runner)]
(wrap []))))
(for {@.old
@@ -129,29 +129,28 @@
## Default
(as-is (exception: #export cannot-continue-running-processes)
- (def: #export run!
- (IO Any)
- (loop [_ []]
- (do {@ io.monad}
- [processes (atom.read runner)]
- (case processes
- ## And... we're done!
- #.Nil
- (wrap [])
-
- _
- (do @
- [#let [now (.nat ("lux io current-time"))
- [ready pending] (list.partition (function (_ process)
- (|> (get@ #creation process)
- (n.+ (get@ #delay process))
- (n.<= now)))
- processes)]
- swapped? (atom.compare-and-swap processes pending runner)]
- (if swapped?
- (do @
- [_ (monad.map @ (get@ #action) ready)]
- (wrap []))
- (error! (ex.construct ..cannot-continue-running-processes []))))
- ))))
+ (def: #export (run! _)
+ (-> Any (IO Any))
+ (do {@ io.monad}
+ [processes (atom.read ..runner)]
+ (case processes
+ ## And... we're done!
+ #.Nil
+ (wrap [])
+
+ _
+ (do @
+ [#let [now (.nat ("lux io current-time"))
+ [ready pending] (list.partition (function (_ process)
+ (|> (get@ #creation process)
+ (n.+ (get@ #delay process))
+ (n.<= now)))
+ processes)]
+ swapped? (atom.compare-and-swap processes pending ..runner)]
+ (if swapped?
+ (do @
+ [_ (monad.map @ (get@ #action) ready)]
+ (run! []))
+ (error! (ex.construct ..cannot-continue-running-processes []))))
+ )))
))