diff options
| author | nodist <kevin.comas.git@gmail.com> | 2026-06-17 19:48:14 -0400 |
|---|---|---|
| committer | nodist <kevin.comas.git@gmail.com> | 2026-06-17 19:48:14 -0400 |
| commit | 4f132dc241f0e9fd0babd34ebf1767e4916fac7c (patch) | |
| tree | de312b52ff9c9bbcb46cc19cb4e0dc6e63a87113 | |
| parent | e5f1630c5ab4c942d3287f92cbb71f34267dc747 (diff) | |
thread id op
| -rw-r--r-- | fib.kpl | 2 | ||||
| -rw-r--r-- | shared_counter.kpl | 8 |
2 files changed, 6 insertions, 4 deletions
@@ -16,7 +16,7 @@ { `panic "invalid type for n" } } ? { - n < 3 { 2 } + n < 2 { 1 } { `sync(fib; n - 1) + fib `sync n - 2 } } ) diff --git a/shared_counter.kpl b/shared_counter.kpl index d5d9efa..f9ae293 100644 --- a/shared_counter.kpl +++ b/shared_counter.kpl @@ -4,13 +4,13 @@ counter : %shared 0 inc_dec : ([amount] - header : %const `format "WHITE#Counter:# " + header : "#BOLD#Thread: %#, #WHITE#Counter:# " `format `thread_id body : ^ counter {[c] c +: amount ? { amount = 1 { "#GREEN#%#" `format c } amount = -1 { "#RED#%#" `format c } - { "INVALID" } + { "#UNDERLINE#INVALID#" } } } `log ,(header; body; "\n") @@ -26,7 +26,7 @@ batch : %const 100 runner : ([fn] total : actions @ total { - `log "#BOLD#WHITE#Batch: #CYAN#% #MAGENTA#%#\n" `format (fn; total) + `log "#WHITE#Batch: #CYAN#% #MAGENTA#%#\n" `format (fn; total) v : Vector[`async_type fn] $ () @ 1 .. batch { v `push `async fn } @ v {[x] `await x } @@ -37,6 +37,8 @@ runner : ([fn] i : runner `async inc d : runner `async dec +`log `format "#YELLOW#SLEEPING...#\n" + `use "time" [Seconds] `use "sys" [sleep] |
