From 69148a9150dda25061e58b0e4f1d24b570939b06 Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Thu, 5 Oct 2023 21:20:11 -0400 Subject: process: Allow running multiple On process blocks on process Turn off share wishes/claims default for subprocesses, so you (for now) have to explicitly specify sharing if you want any to happen. On process now only spawns process if it doesn't exist but always runs the code block (which now happens through a statement instead of directly on init). --- lib/process.tcl | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'lib/process.tcl') diff --git a/lib/process.tcl b/lib/process.tcl index 059c0b89..b5d2952b 100644 --- a/lib/process.tcl +++ b/lib/process.tcl @@ -57,21 +57,32 @@ namespace eval ::Zygote { } proc On-process {name body} { + if {[namespace exists ::Peers::$name]} { + uplevel [list Wish program code $body runs on $name] + return + } + set this [uplevel {expr {[info exists this] ? $this : ""}}] - set processCode [list apply {{__parentProcess __name __body} { + set processCode [list apply {{__parentProcess __name} { set ::thisProcess $__name - Assert wishes $::thisProcess shares all wishes - Assert wishes $::thisProcess shares all claims - ::peer $__parentProcess true + Assert wishes $::thisProcess shares statements like \ + [list /someone/ claims $::thisProcess has pid /something/] + Assert wishes $::thisProcess receives statements like \ + [list /someone/ wishes program code /code/ runs on $::thisProcess] + Assert wishes $::thisProcess shares statements like \ + [list /someone/ wishes $::thisProcess receives statements like /pattern/] + Assert claims $::thisProcess has pid [pid] - Assert when $::thisProcess has pid /something/ [list {} $__body] + Assert when /someone/ wishes program code /__code/ runs on $::thisProcess {{__code} { + eval $__code + }} while true { Step } - }} $::thisProcess $name $body] + }} $::thisProcess $name] ::peer $name false @@ -107,4 +118,5 @@ proc On-process {name body} { after 5000 [list dict unset ::peersBlacklist $name] } }} $this $name + uplevel [list Wish program code $body runs on $name] } -- cgit v1.2.3 From f4356b98d2041d8188ae61d1025a98db7becdee0 Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Fri, 6 Oct 2023 17:41:15 -0400 Subject: display: WIP: Refactor into files; use wishes, not Display:: Expose shader stuff to user programs for the first time. Mostly works, but display thread and main thread run much slower (28fps display, 70fps main). Also introduce dict getwithdefault (helpful for rest options). --- lib/process.tcl | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'lib/process.tcl') diff --git a/lib/process.tcl b/lib/process.tcl index b5d2952b..faaa5e84 100644 --- a/lib/process.tcl +++ b/lib/process.tcl @@ -56,14 +56,14 @@ namespace eval ::Zygote { } } -proc On-process {name body} { +proc Start-process {name body} { if {[namespace exists ::Peers::$name]} { - uplevel [list Wish program code $body runs on $name] + error "Process $name already exists" return } set this [uplevel {expr {[info exists this] ? $this : ""}}] - set processCode [list apply {{__parentProcess __name} { + set processCode [list apply {{__parentProcess __name __body} { set ::thisProcess $__name ::peer $__parentProcess true @@ -76,13 +76,16 @@ proc On-process {name body} { [list /someone/ wishes $::thisProcess receives statements like /pattern/] Assert claims $::thisProcess has pid [pid] - Assert when /someone/ wishes program code /__code/ runs on $::thisProcess {{__code} { - eval $__code - }} - while true { - Step - } - }} $::thisProcess $name] + # Run __body one Step before running any other program code. + Assert when $::thisProcess has pid /something/ [list {__body} { + When /someone/ wishes program code /__code/ runs on $::thisProcess { + eval $__code + } + eval $__body + }] with environment [list $__body] + + while true { Step } + }} $::thisProcess $name $body] ::peer $name false @@ -118,5 +121,4 @@ proc On-process {name body} { after 5000 [list dict unset ::peersBlacklist $name] } }} $this $name - uplevel [list Wish program code $body runs on $name] } -- cgit v1.2.3