Typically developers do not use the spawn functions, instead they use abstractions such as …
So where do non-typical developers go to find out how to use functions that are in the manual?
I’m using the spawn functions so I can get my head around the agent / message sending thing, and understand how it works before I start using the abstractions.
I’ve already written code that uses spawn_monitor on one node … but now I’m trying to play with using another “remote” node. I was assuming there would be an equivalent spawn_monitor in Node, but apparently not. So now I’m looking at how to hand spawn_link … but there is nothing in the manual.
PS… I got my instruction on how to use the spawn_Monitor from “Programming Elixir” book … there’s no way I could have grok-ed the spawn functions without that external resource (so thanks Dave Thomas!).
@Astonj - yeah opposite … I’m learn by mistakes. Do it, get it wrong(maybe) and work out why. I find I come out with a better understanding.
So I found
that makes the spawning process get back an :EXIT message, like a spawn_monitor gets a :DOWN message.
Right. Now it runs remotely … but, it runs slower. Learning moment.
And now I think I have learnt that you have to really think about where the messages are going. What works in a single node doesn’t automatically work with a cluster of nodes.
I think the problem is that the remotely spawned processes are sending the results it generates (there are lots of them) back to the spawning process so it can evaluate and find the best. That ends up being slower that doing everything on the one node.
I have to now restructure the program so each process manages it’s own set of results, and pass the best back at the end, so I have one result per process.
Please tell me where the any of the Elixir or Erlang manuals make any reference to what happens in the process that calls any of the spawn_link functions, apart from the spawn_link call return values …
My claim remains, you have to know how it works for the docs to actually be useful.
The tell you that those processes are linked. That’s it. You can not implement this link or a monitor on your own. It’s a feature of the BEAM. Asking for a way to implement it on your own is like asking how to reimplement MOV or STO in assembler.