[erlang-questions] Imagine every (active) entity is a process

Ulf Wiger (TN/EAB) ulf.wiger@REDACTED
Tue Nov 6 09:27:27 CET 2007


Alexander Lamb wrote:
> 
> Isn't there a race condition here. Since I have to check first if a  
> process exists before creating it, I might end up in a situation where  
> two other processes are doing the same thing and creating twice a  
> process for the same entity. The second would obviously fail and we  
> could catch the error. But is this a correct way of proceeding? Also,  
> is it possible to have thousands of registered processes (as opposed  
> to non registered processes)?

You will find a contrib called dispatcher at Trapexit.
It does pretty much exactly what you're asking for, including
taking care of the inherent race condition.

http://forum.trapexit.org/viewtopic.php?p=30165#30165

BR,
Ulf W



More information about the erlang-questions mailing list