From 8c90251c12a4d0d4cc191bfb273bb5eb51bb0356 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 8 May 2018 22:30:03 -0400 Subject: - Re-named "lux process concurrency-level" to "lux process parallelism-level". - Merged the functionality of "lux process future" into "lux process schedule". --- .../lang/translation/lua/procedure/common.jvm.lux | 9 ++----- .../luxc/lang/translation/lua/runtime.jvm.lux | 29 ++++++++++------------ 2 files changed, 15 insertions(+), 23 deletions(-) (limited to 'new-luxc/source/luxc/lang/translation/lua') 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) - (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) -- cgit v1.2.3