diff options
author | Eduardo Julian | 2018-07-31 20:22:15 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-07-31 20:22:15 -0400 |
commit | 7e44ee8a2cfb14e35f6283a9eb8d6a2ddc8bd99a (patch) | |
tree | 98a12aa5a9fd347c1070612a2a1dae69dae879b1 /new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux | |
parent | eea58ee669f69fddf2cef9e1675c41959e2e0a55 (diff) |
Now implementing process functionality in stdlib instead of the compiler.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux index 3a18f98e7..ce9c37db5 100644 --- a/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux @@ -258,50 +258,6 @@ Runtime (format @@box//write)) -(def: process//incoming - Text - (lang.normalize-name "process//incoming")) - -(runtime: (process//loop _) - (let [migrate-incoming! (lua.block! (list (lua.for-step! "idx" (lua.int 1) (lua.length process//incoming) (lua.int 1) - (lua.apply "table.insert" (list "queue" (lua.nth "idx" process//incoming)))) - (lua.set! process//incoming (lua.array (list))))) - consume-queue! (lua.block! (list (lua.local! "survivors" (#.Some (lua.array (list)))) - (lua.local! "active_processes" (#.Some (lua.length "queue"))) - (lua.for-step! "idx" (lua.int 1) "active_processes" (lua.int 1) - (lua.block! (list (lua.local! "process" (#.Some (lua.nth "idx" "queue"))) - (lua.when! (lua.apply "coroutine.resume" (list "process")) - (lua.apply "table.insert" (list "survivors" "process")))))) - (lua.set! "queue" "survivors"))) - loop-body! (lua.block! (list migrate-incoming! - consume-queue!))] - (lua.block! (list (lua.local! "queue" (#.Some (lua.array (list)))) - loop-body! - (lua.while! (|> (lua.length "queue") (lua.> (lua.int 0))) - loop-body!))))) - -(runtime: (process//schedule milli-seconds procedure) - (let [now (lua.apply "os.time" (list))] - (lua.if! (lua.= (lua.int 0) milli-seconds) - (lua.apply "table.insert" (list process//incoming - (lua.function (list) - (lua.return! (lua.apply procedure (list unit)))))) - (lua.block! (list (lua.local! "start" (#.Some now)) - (lua.local! "seconds" (#.Some (lua.// (lua.int 1_000) - milli-seconds))) - (lua.apply "table.insert" (list process//incoming - (lua.function (list) - (lua.block! (list (lua.while! (lua.< "seconds" (lua.- "start" now)) - (lua.apply "coroutine.yield" (list))) - (lua.return! (lua.apply procedure (list unit)))))))) - (lua.return! unit)))))) - -(def: runtime//process - Runtime - (format (lua.global! process//incoming (#.Some (lua.array (list)))) - @@process//loop - @@process//schedule)) - (runtime: (lua//get object field) (lua.block! (list (lua.local! "value" (#.Some (lua.nth field object))) (lua.if! (lua.= lua.nil "value") @@ -325,7 +281,6 @@ runtime//text runtime//array runtime//box - runtime//process runtime//lua)) (def: #export artifact Text (format prefix ".lua")) |