summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglenda <glenda@cirno>2022-09-13 15:47:03 +0000
committerglenda <glenda@cirno>2022-09-13 15:47:03 +0000
commit34adf252d179556df7d8277370e735c56c6ab3f5 (patch)
treeacc0be499165bcd15975263f26be87a833800dc2
parentcb3dbf22c21ef2d4ad43f718dd9360b7f4008cc8 (diff)
Update demo
-rwxr-xr-xAPLDemo3
-rw-r--r--demos/doubleup.apl27
2 files changed, 18 insertions, 12 deletions
diff --git a/APLDemo b/APLDemo
index fbf85b5..106b37d 100755
--- a/APLDemo
+++ b/APLDemo
@@ -3,6 +3,9 @@
winid=`{grep -e '-apl' /mnt/acme/index | awk '{print $1}' }
if(~ $#winid 0){
win apl &
+ sleep 1
+ winid=`{grep -e '-apl' /mnt/acme/index | awk '{print $1}' }
+ rm /tmp/apldemo.$winid.state
exit
}
diff --git a/demos/doubleup.apl b/demos/doubleup.apl
index 44d3cd9..0206528 100644
--- a/demos/doubleup.apl
+++ b/demos/doubleup.apl
@@ -1,38 +1,41 @@
⍝ Define the "double up" function
f←{
- (who message)←{1 ⍵} RECV ⍬ ⍝ Recieve a message with no timeout
- (2×message) SEND who ⍝ Reply with 2×message
- ∇⍵ ⍝ Recurse
+ (who message)←{1 ⍵}⍇⍬ ⍝ Recieve a message with no timeout
+ (2×message)⍈who ⍝ Reply with 2×message
+ ∇⍵ ⍝ Recurse
}
⍝ Spawn it as a seperate thread
id←f&'double up'⊢⍬
⍝ Check it's status (id, name, mails in mailbox)
-id ⎕tasks 0 1 4
+id ⎕threads 0 1 4
⍝ Check our own status
-⎕self ⎕tasks 0 1 4
+⎕self ⎕threads 0 1 4
⍝ Send a few messages to our own mailbox
-'hello' SEND ⎕self
-(⍳2 2) SEND ⎕self
+'hello'⍈⎕self
+(⍳2 2)⍈⎕self
⍝ Send a message to the double up thread
-(⍳5) SEND id
+(⍳5)⍈id
+
+⍝ Send a message to ourself again
+'last one'⍈⎕self
⍝ Check our own status again
-⎕self ⎕tasks 0 1 4
+⎕self ⎕threads 0 1 4
⍝ We now have a few messages, but we want a specific one..
⍝ That is, the one where the sender = id
-{id=⊃⍵:1 ⍵ ⋄ 0} RECV 0
+{id=⊃⍵:1 ⍵ ⋄ 0}⍇0
⍝ We might as well get the other messages as well
flush←{
12::⍵ ⍝ Stop when we get a timeout error
- m←{1 ⍵} RECV 0
+ m←{1 ⍵}⍇0
∇⍵,⊂m
}
-flush ⍬ \ No newline at end of file
+flush ⍬