diff options
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/lua')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux | 9 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux | 29 |
2 files changed, 15 insertions, 23 deletions
diff --git a/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux index 3c8f94557..f3b437444 100644 --- a/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux @@ -390,14 +390,10 @@ (runtimeT.box//write valueO boxO)) ## [[Processes]] -(def: (process//concurrency-level []) +(def: (process//parallelism-level []) Nullary (lua.int 1)) -(def: process//future - Unary - runtimeT.process//future) - (def: (process//schedule [milli-secondsO procedureO]) Binary (runtimeT.process//schedule milli-secondsO procedureO)) @@ -536,8 +532,7 @@ Bundle (<| (prefix "process") (|> (dict.new text.Hash<Text>) - (install "concurrency-level" (nullary process//concurrency-level)) - (install "future" (unary process//future)) + (install "parallelism-level" (nullary process//parallelism-level)) (install "schedule" (binary process//schedule)) ))) 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 03d84f400..70b498dfa 100644 --- a/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux @@ -334,29 +334,26 @@ (lua.while! (|> (lua.length "queue") (lua.> (lua.int 0))) loop-body!))))) -(runtime: (process//future procedure) - (lua.block! (list (lua.apply "table.insert" (list process//incoming - (lua.function (list) - (lua.return! (lua.apply procedure (list unit)))))) - (lua.return! unit)))) - (runtime: (process//schedule milli-seconds procedure) (let [now (lua.apply "os.time" (list))] - (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))))) + (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//future @@process//schedule)) (runtime: (lua//get object field) |