repo.or.cz
/
minnow.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Initial commit
[minnow.git]
/
samples
/
threadring.mno
blob
347f009a0780ef6d4921f4e02f2a7188d8a06aa5
1
actor Passer
2
var int m_id
3
var Passer m_next
4
5
action pass(int token)
6
if (token == 0)
7
puti(m_id)
8
exit(0)
9
else
10
token = token - 1
11
m_next::pass(token)
12
end
13
end
14
15
action setIdAndNext(int id, Passer next)
16
m_id = id
17
m_next = next
18
end
19
end
20
21
action main(string[] args)
22
spawn Passer[] passers[503]
23
var int i = 0
24
while (i < 502)
25
passers[i]::setIdAndNext(i+1, passers[i+1])
26
i = i + 1
27
end
28
passers[502]::setIdAndNext(503, passers[0])
29
30
passers[0]::pass(convertToInt(args[0]))
31
done
32
end
33