fiv
Trying to wrap my head around how processes pass messages. I have a simple example of processA sending a message to processB
defmodule ProcessA do
def start() do
spawn fn -> run() end
end
def run do
run()
end
end
defmodule ProcessB do
def start do
spawn fn -> run() end
end
def run do
run()
end
end
iex(1)> process_a = ProcessA.start
#PID<0.153.0>
iex(2)> process_b = ProcessB.start
#PID<0.154.0>
iex(3)> send(process_b, "Hello")
"Hello"
iex(4)> Process.info(process_b, :messages)
{:messages, ["Hello"]}
When I use the send function the Iex process is sending a message to process_b.
I don’t understand how process_a can send a message to process_b.
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
I think I’ve found a small improvement I could contribute to <%= web_namespace %>.CoreComponents (installer/templates/phx_web/compo...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
Every process can send another process a message if it knows how to reference it. Obviously that’s not doing being done willy-nilly but it’s a feature that is widely used and is a core tenet of the OTP.
Samjowen
You’ll have to dive into the Erlang source code if you want to see the guts of the function!
codeanpeace
Yup!
You can send a message to
process_athat tells it to send a message toprocess_b.Here’s a quick example where the
iex processsends a message toprocess_awhich then sends that message toprocess_balong with theiex processpid so thatprocess_bcan notify theiex processthat the message was received.sodapopcan
I’m not sure but based on your naming scheme I think you may be conflating modules and processes. This is a fairly common mistake. A process is a distinct, self-contained concept that runs code and stores state whereas modules are merely static bags of functions that can be call from any process.
Hermanverschooten
Every process has a
pid, if you know thispidyou can send a message to it.That is what you are doing when you write
process_b = ProcessB.start.You are saving the
pidin the variableprocess_b.There are several methods that allow you to make the
pidof one process available to another, for example using theRegistry.