diff options
Diffstat (limited to 'demos/chain.apl')
-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 |