diff options
author | Eduardo Julian | 2020-08-07 20:56:37 -0400 |
---|---|---|
committer | Eduardo Julian | 2020-08-07 20:56:37 -0400 |
commit | a84e20e455f4d8ab86dd5a20c333bace11a56104 (patch) | |
tree | 6742d8b32eacfa9856b05c6110995a94402a5ec6 /stdlib/source/lux/control/concurrency/process.lux | |
parent | 268c21aa6867263b890f5dd2b3038a675bc915f7 (diff) |
Some fixes.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/control/concurrency/process.lux | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/stdlib/source/lux/control/concurrency/process.lux b/stdlib/source/lux/control/concurrency/process.lux index dd38e3041..04bfbbbae 100644 --- a/stdlib/source/lux/control/concurrency/process.lux +++ b/stdlib/source/lux/control/concurrency/process.lux @@ -55,7 +55,10 @@ (host.import: #long java/util/concurrent/ScheduledThreadPoolExecutor (new [int]) - (schedule [java/lang/Runnable long java/util/concurrent/TimeUnit] #io (java/util/concurrent/ScheduledFuture java/lang/Object))))} + (schedule [java/lang/Runnable long java/util/concurrent/TimeUnit] #io (java/util/concurrent/ScheduledFuture java/lang/Object)))) + + @.js + (as-is (host.import: (setTimeout [host.Function host.Number] Any)))} ## Default (type: Process @@ -79,16 +82,21 @@ ## Default 1)) -(def: runner - (for {@.old - (java/util/concurrent/ScheduledThreadPoolExecutor::new (.int ..parallelism)) +(for {@.old + (def: runner + (java/util/concurrent/ScheduledThreadPoolExecutor::new (.int ..parallelism))) - @.jvm - (java/util/concurrent/ScheduledThreadPoolExecutor::new (.int ..parallelism))} - - ## Default - (: (Atom (List Process)) - (atom.atom (list))))) + @.jvm + (def: runner + (java/util/concurrent/ScheduledThreadPoolExecutor::new (.int ..parallelism))) + + @.js + (as-is)} + + ## Default + (def: runner + (Atom (List Process)) + (atom.atom (list)))) (def: #export (schedule milli-seconds action) (-> Nat (IO Any) (IO Any)) @@ -110,7 +118,11 @@ (case milli-seconds 0 (java/util/concurrent/Executor::execute runnable runner) _ (java/util/concurrent/ScheduledThreadPoolExecutor::schedule runnable (.int milli-seconds) java/util/concurrent/TimeUnit::MILLISECONDS - runner)))} + runner))) + + @.js + (io.io (..setTimeout [(host.closure [] (io.run action)) + (n.frac milli-seconds)]))} ## Default (do io.monad @@ -124,6 +136,9 @@ (as-is) @.jvm + (as-is) + + @.js (as-is)} ## Default |