Concurrency

Atomo uses message-passing concurrency akin to Erlang. Processes are very cheap to spawn and kill, and you can send messages to them or wait to receive values.

Process  Object

A green thread, bound to a communications channel and a process ID.

self  Process

Returns the current Process.

Example:

> self
<process 5>
receive  any

Waits for a message, blocking until one is received.

Example:

> { main | "hello!" print; main <- @done } spawn: self
hello!
<process 51>
> receive
@done
b spawn  Process
  | b is-a?: Block

Executes b call in a separate process, and returns that new process.

Example:

> { (1 + 1) print } spawn
2
<process 52>
b spawn: (... args)  Process
  | b is-a?: Block

Like spawn, but executes b call: args instead.

Example:

> { a | (a + 1) print } spawn: 41
42
<process 53>
p <- v  p
  | p is-a?: Process

Sends the value v to process p, and returns p.

Example:

> p = { receive <- @pong } spawn
<process 54>
> p <- self
<process 54>
> receive
@pong
p stop  @ok
  | p is-a?: Process

Immediately kills the process p.

halt  @ok

Immediately shuts down the Atomo VM, when called from any process.