diff options
author | glenda <glenda@cirno> | 2022-09-14 08:26:29 +0000 |
---|---|---|
committer | glenda <glenda@cirno> | 2022-09-14 08:26:29 +0000 |
commit | 544f90f798a7ebd76b71f094d4cd77f6166e606b (patch) | |
tree | e8ce5356dc52300bbe9aaa8fc460c6e0f179d37e /demos/chain.apl | |
parent | 2c2af66200badebe076570038daf4cacf47a1281 (diff) |
More demos, and lock thread spawning
Diffstat (limited to 'demos/chain.apl')
-rw-r--r-- | demos/chain.apl | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/demos/chain.apl b/demos/chain.apl new file mode 100644 index 0000000..e7e1979 --- /dev/null +++ b/demos/chain.apl @@ -0,0 +1,18 @@ +⍝ First we define a function which recieves a message, +⍝ and sends one to the task with id ⍵ +f←{ + (from msg)←{1 ⍵}⍇⍬ + (1+msg)⍈⍵ + } + +⍝ Now start 10000 of those +last←f&'chain'⍣10000⊢⎕self + +≢⎕THREADS 0 + +⍝ Start the chain by sending something to the last one +0 ⍈ last + +⎕threads 0 1 2 + +{1 (2⊃⍵)}⍇0 ⍝ We only pick out the message part, not the sender |