From 544f90f798a7ebd76b71f094d4cd77f6166e606b Mon Sep 17 00:00:00 2001 From: glenda Date: Wed, 14 Sep 2022 08:26:29 +0000 Subject: More demos, and lock thread spawning --- demos/chain.apl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 demos/chain.apl (limited to 'demos/chain.apl') 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 -- cgit v1.2.3