Skip to content

Commit

Permalink
examples: Add comments for ring example
Browse files Browse the repository at this point in the history
  • Loading branch information
palash25 authored and SeanTAllen committed Apr 10, 2020
1 parent 2bf65c0 commit 91ecfb2
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions examples/ring/main.pony
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
"""
A ring is a group of processes connected to each other using
unidirectional links through which messages can pass from process to
process in a cyclic manner.
The logic of this program is as follows:
* Each process in a ring is represented by the actor `Ring`
* `Main` creates Ring by instantiating `Ring` actors based on the
arguments passed and links them with each other by setting the next
actor as the previous ones number and at the end linking the last actor
to the first one thereby closing the links and completing the ring
* Once the ring is complete messages can be passed by calling the `pass`
behaviour on the current `Ring` to its neighbour.
* The program prints the id of the last `Ring` to receive a message
For example if you run this program with the following options `--size 3`
and `--pass 2`. It will create a ring that looks like this:
* * * *
* * * *
* 1 *_ _ _ * 2 *
* * * *
* * * *
* * * *
\ /
\ /
\ /
\ * * /
* *
* 3 *
* *
* *
* *
and print 3 as the id of the last Ring actor that received the
message.
"""

use "collections"

actor Ring
Expand Down

0 comments on commit 91ecfb2

Please sign in to comment.