{"id":24736300,"url":"https://github.com/b0nam/elixir-process-ring","last_synced_at":"2025-03-22T17:22:34.620Z","repository":{"id":213771466,"uuid":"734894380","full_name":"B0nam/ELIXIR-PROCESS-RING","owner":"B0nam","description":"Process ring implemented in Elixir using processeses. ","archived":false,"fork":false,"pushed_at":"2024-03-25T19:18:04.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-27T21:24:17.701Z","etag":null,"topics":["elixir","process-ring","processes","ring"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/B0nam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-12-22T23:58:08.000Z","updated_at":"2023-12-23T00:00:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"22ad4323-0625-42d5-909d-f3f30ef14696","html_url":"https://github.com/B0nam/ELIXIR-PROCESS-RING","commit_stats":null,"previous_names":["b0nam/elixir-process-ring"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/B0nam%2FELIXIR-PROCESS-RING","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/B0nam%2FELIXIR-PROCESS-RING/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/B0nam%2FELIXIR-PROCESS-RING/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/B0nam%2FELIXIR-PROCESS-RING/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/B0nam","download_url":"https://codeload.github.com/B0nam/ELIXIR-PROCESS-RING/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244992427,"owners_count":20543813,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","process-ring","processes","ring"],"created_at":"2025-01-27T21:24:35.024Z","updated_at":"2025-03-22T17:22:34.590Z","avatar_url":"https://github.com/B0nam.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ELIXIR-PROCESS-RING\n\n Process ring implemented in Elixir using processeses. \n\n## Overview\n\nThis project implements a process ring in Elixir. A process ring is a system of concurrent processes, where each process is linked to its next neighbor in a circular manner. The processes communicate by passing messages in a ring fashion.\n\n## Usage\n\nTo create the process ring, follow these steps:\n\n1. Open process_ring.exs using iex:\n\n    ```bash\n    iex process_ring.exs\n    ```\n\n2. Create a list of processes using create_processes():\n\n    ```elixir\n    process_list = ProcessRing.create_processes(10) # Replace 10 with the desired number of processes\n    ```\n\n3. Create a process ring using create_ring()\n\n    ```elixir\n    ring = ProcessRing.create_ring(process_list) # Use the list of processes created previously\n    ```\n\n4. Start the ring:\n\n    ```elixir\n    ProcessRing.start_ring(ring)\n    ```\n\n## Project Structure\n\n- `ProcessRing.ex`: Contains the main module defining functions for creating processes, building the ring, starting the ring, and handling message passing.\n\n## Functions\n\n### `create_processes(size)`\n\nCreates processes with the given size.\n\n### `create_ring(processes_list)`\n\nCreates a ring from a list of processes, setting their positions on the ring.\n\n### `start_ring(ring)`\n\nStarts the ring by sending a message to the first process.\n\n### `process_listener()`\n\nListens for messages and forwards them to the next process in the ring.\n\n### `send_message(process_pid, ring, position)`\n\nSends a message to the given process ID, displaying a log. If the position is 0, it indicates the start of a new cycle.\n\nCertainly! I've refined the example session and separated it into sections with explanations:\n\n## Example\n\n### 1. Create Processes\n\n```elixir\niex(1)\u003e process_list = ProcessRing.create_processes(10)\n[#PID\u003c0.116.0\u003e, #PID\u003c0.117.0\u003e, #PID\u003c0.118.0\u003e, #PID\u003c0.119.0\u003e, #PID\u003c0.120.0\u003e, #PID\u003c0.121.0\u003e, #PID\u003c0.122.0\u003e, #PID\u003c0.123.0\u003e, #PID\u003c0.124.0\u003e, #PID\u003c0.125.0\u003e]\n```\n\nIn this step, we create a list of 10 processes. Each process is represented by a unique PID.\n\n### 2. Create Process Ring\n\n```elixir\niex(2)\u003e ring = ProcessRing.create_ring(process_list)\n[\n  %{pid: #PID\u003c0.116.0\u003e, position: 0, next_process: #PID\u003c0.117.0\u003e},\n  %{pid: #PID\u003c0.117.0\u003e, position: 1, next_process: #PID\u003c0.118.0\u003e},\n  %{pid: #PID\u003c0.118.0\u003e, position: 2, next_process: #PID\u003c0.119.0\u003e},\n  %{pid: #PID\u003c0.119.0\u003e, position: 3, next_process: #PID\u003c0.120.0\u003e},\n  %{pid: #PID\u003c0.120.0\u003e, position: 4, next_process: #PID\u003c0.121.0\u003e},\n  %{pid: #PID\u003c0.121.0\u003e, position: 5, next_process: #PID\u003c0.122.0\u003e},\n  %{pid: #PID\u003c0.122.0\u003e, position: 6, next_process: #PID\u003c0.123.0\u003e},\n  %{pid: #PID\u003c0.123.0\u003e, position: 7, next_process: #PID\u003c0.124.0\u003e},\n  %{pid: #PID\u003c0.124.0\u003e, position: 8, next_process: #PID\u003c0.125.0\u003e},\n  %{pid: #PID\u003c0.125.0\u003e, position: 9, next_process: #PID\u003c0.116.0\u003e}\n]\n```\n\nHere, we create a process ring using the previously generated list of processes. Each entry in the list represents a process in the ring, with information about its PID, position, and the PID of its next neighbor.\n\n### 3. Start the Process Ring\n\n```elixir\niex(3)\u003e ProcessRing.start_ring(ring)\n[.] #PID\u003c0.115.0\u003e SENT A MESSAGE TO #PID\u003c0.116.0\u003e\n:ok\n\n[+] New Cycle Started.\n[.] #PID\u003c0.116.0\u003e SENT A MESSAGE TO #PID\u003c0.117.0\u003e\n[.] #PID\u003c0.117.0\u003e SENT A MESSAGE TO #PID\u003c0.118.0\u003e\n[.] #PID\u003c0.118.0\u003e SENT A MESSAGE TO #PID\u003c0.119.0\u003e\n[.] #PID\u003c0.119.0\u003e SENT A MESSAGE TO #PID\u003c0.120.0\u003e\n[.] #PID\u003c0.120.0\u003e SENT A MESSAGE TO #PID\u003c0.121.0\u003e\n[.] #PID\u003c0.121.0\u003e SENT A MESSAGE TO #PID\u003c0.122.0\u003e\n[.] #PID\u003c0.122.0\u003e SENT A MESSAGE TO #PID\u003c0.123.0\u003e\n[.] #PID\u003c0.123.0\u003e SENT A MESSAGE TO #PID\u003c0.124.0\u003e\n[.] #PID\u003c0.124.0\u003e SENT A MESSAGE TO #PID\u003c0.125.0\u003e\n[.] #PID\u003c0.125.0\u003e SENT A MESSAGE TO #PID\u003c0.116.0\u003e\n\n[+] New Cycle Started.\n[.] #PID\u003c0.116.0\u003e SENT A MESSAGE TO #PID\u003c0.117.0\u003e\n[.] #PID\u003c0.117.0\u003e SENT A MESSAGE TO #PID\u003c0.118.0\u003e\n[.] #PID\u003c0.118.0\u003e SENT A MESSAGE TO #PID\u003c0.119.0\u003e\n...\n```\n\nFinally, we start the process ring, and you can observe the messages being passed between processes. A new cycle starts after each round, demonstrating the circular communication pattern.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb0nam%2Felixir-process-ring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fb0nam%2Felixir-process-ring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb0nam%2Felixir-process-ring/lists"}