diff options
author | glenda <glenda@cirno> | 2022-09-14 08:41:54 +0000 |
---|---|---|
committer | glenda <glenda@cirno> | 2022-09-14 08:41:54 +0000 |
commit | 4f85698062f9283b8b7fcc6dacc256c786c22210 (patch) | |
tree | 9119974f0ce7f93c7bf3f428fc887cfe797dc2b0 | |
parent | 544f90f798a7ebd76b71f094d4cd77f6166e606b (diff) |
Improve chain demo
-rw-r--r-- | demos/chain.apl | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/demos/chain.apl b/demos/chain.apl index e7e1979..b570d51 100644 --- a/demos/chain.apl +++ b/demos/chain.apl @@ -1,18 +1,23 @@ -⍝ First we define a function which recieves a message, -⍝ and sends one to the task with id ⍵ +⍝ First we define a function which recieves a message msg, +⍝ and sends (1+msg) to the task with id ⍵ f←{ (from msg)←{1 ⍵}⍇⍬ (1+msg)⍈⍵ } -⍝ Now start 10000 of those -last←f&'chain'⍣10000⊢⎕self +⍝ Now start 1000 of those +⊢last←f&'chain'⍣1000 ⊢ ⎕self +⍝ Verify that over 1000 threads are running ≢⎕THREADS 0 -⍝ Start the chain by sending something to the last one -0 ⍈ last +⍝ Start the chain by sending something to the last one, +⍝ and wait for a result +run←{ + _←⍵⍈last + {1 (2⊃⍵)}⍇⍬ + } +run 0 ⍝ Run it! ⎕threads 0 1 2 -{1 (2⊃⍵)}⍇0 ⍝ We only pick out the message part, not the sender |