Skip to content

Commit addc943

Browse files
committed
More details in final report
1 parent 8ad788d commit addc943

File tree

1 file changed

+43
-7
lines changed

1 file changed

+43
-7
lines changed

docs-source/ruby-association-final-report.md

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,56 @@ therefore they will be able to reuse their knowledge in Ruby.
1414

1515
## Erlang actors
1616

17-
The actor implementation matches the Erlang's implementation.
18-
Mainly it has the same:
19-
* exit behavior (called termination in Ruby to avoid collision with `Kernel#exit`),
20-
* ability to link and monitor actors,
21-
* ability to have much more actors then threads,
22-
* ordering guarantees between messages and signals,
23-
* message receiving features.
17+
The actor implementation matches the Erlang's implementation.
18+
Mainly:
19+
20+
* The `exit/1` and `exit/2`
21+
functions are reimplemented with the same arguments and effects.
22+
Even though the methods are named `terminate` to avoid collision with `Kernel#exit`.r
23+
This re-implementation adds that the termination event not only sends signals to linked actors
24+
but it is represented as a Future
25+
which is fulfilled with the final value of the actor or rejected with the reason of abnormal termination.
26+
27+
* The linking and monitoring between actors (called processes in Erlang) is re-implemented.
28+
Functions `link`, `unlink`, `spawn_link`, `monitor`, `demonitor`, `spawn_monitor`
29+
have equivalent counterparts
30+
`link`, `unlink`, `spawn link:true`, `monitor`, `demonitor`, `spawn monitor: true`.
31+
All the options applicable in this implementation are supported,
32+
they effects are the same
33+
and the ordering of signal and messages is the same as on Erlang.
34+
35+
* This implementation has two functionally equivalent types of actors
36+
`spawn type: on_thread, ...` and `spawn type: on_pool, ...`.
37+
They differ in the execution mode.
38+
First requires its own thread second runs on shared thread pool
39+
therefore allowing to have millions of short or long lived actors if required.
40+
41+
* Message and signal ordering of messages between two actors has same guarantee as in Erlang.
42+
Messages and signals from A are always received by B in the order they were send.
43+
(Signals are internal messages produced by methods like `link`.)
44+
The ordering guarantee does not scale up to more than 2 actors in Erlang nor in this implementation.
45+
46+
* Even though Ruby does not have pattern matching, this implementation provides `receive`
47+
which is functionally equivalent.
48+
(It is sometimes more cumbersome to use though.)
49+
50+
Exit behaviour, linking, and monitoring is very well described by
51+
[the chapter of the book "learn you some Erlang"](https://learnyousomeerlang.com/errors-and-processes).
52+
This implementation matches the behaviours described there.
53+
54+
Erlang method documentation can be found at
55+
<http://erlang.org/documentation/doc-10.3/erts-10.3/doc/html/erlang.html>.
56+
57+
### Actor execution modes - types
2458

2559
The actors can be written in 2 modes. First will require it's own thread,
2660
second will run on a thread pool.
2761
Please see
2862
[Actor types section](http://blog.pitr.ch/concurrent-ruby/master/Concurrent/ErlangActor.html)
2963
for more details.
3064

65+
### Ordering
66+
3167
Especially ordering guarantees are not easy to get correct.
3268
As an example lets have a look at the reasoning behind implementation of monitoring.
3369
Understanding of the monitors in Erlang actors is necessary for the following part.

0 commit comments

Comments
 (0)