diff options
| -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] |
