blob: 43da2b68fce77768a104af868d9847e6c925eb99 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
⍝ The send primitive is a dyadic function
⍝ message ⍈ to
message←'Hello there'
⍝ We can send it to ourselves
us←⎕self
us
message ⍈ us
⍝ Let's examine the state of the system
us ⎕threads 0 ⍝ Thread ID
us ⎕threads 1 ⍝ Thread name
us ⎕threads 2 ⍝ Number of messages in mailbox
us ⎕threads 3 ⍝ Approximate C stack usage (in bytes)
us ⎕threads 4 ⍝ Number of dfn stack frames
⍝ All at once, for all currently running threads
⎕threads 0 1 2 3 4
⍝ We have one message in our mailbox, let's receive it
⍝ The recieve primitive is a monadic operator
⍝ filter ⍇ timeout
{1 ⍵} ⍇ 0
⍝ Again?
{1 ⍵} ⍇ 0
⍝ The time we asked it to wait was 0, so it failed immediately.
{1 ⍵} ⍇ 5
⍝ What if we don't want it to timeout?
{1 ⍵} ⍇ ⍬ ⍝ No one will send it anything, so it hangs
|