This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
cs326:lab5 [2021/10/24 23:03] scarl |
cs326:lab5 [2021/10/24 23:03] scarl |
||
---|---|---|---|
Line 13: | Line 13: | ||
* If you want to try stress-testing with 100 million processes, do it **last**...and on the Linux box, not a laptop. | * If you want to try stress-testing with 100 million processes, do it **last**...and on the Linux box, not a laptop. | ||
| | ||
- | | ||
- | <code> | ||
- | # Table - lessons on using processes and message-passing from http://eddwardo.github.io/ | ||
- | # | ||
- | # version one: spawn a process running a tail-recursive fcn that does nothing but receive :ping messages | ||
- | # | ||
- | |||
- | defmodule Table do | ||
- | def ping do | ||
- | receive do | ||
- | :ping -> IO.puts('received ping') | ||
- | end | ||
- | ping() | ||
- | end | ||
- | |||
- | def start do | ||
- | IO.puts __MODULE__ | ||
- | # as shown by the IO.puts, __MODULE__ evaluates to the (fully-qualified) module name | ||
- | spawn(__MODULE__, :ping, []) | ||
- | end | ||
- | end | ||
- | </code> | ||
- | |||
- |