Skip to content

Synchronization using await 1

uwiger edited this page Aug 15, 2011 · 1 revision

Designing a robust startup sequence in a complex system is a very difficult task.

Erlang/OTP offers some assistance with application dependencies, but these are fairly coarse-grained, and offer no help if (heaven forbid) dependencies are somewhat circular in nature.

Gproc provides a simple synchronization mechanism in the form of gproc:await(Name). This function works like gproc:where(Name), but will work even if Name is not yet registered; in this case, it will block until someone does register it.

Gproc allows a process to have several unique names, so processes can use this facility to register a name announcing that "I am now ready to serve requests of type X". This way, gproc becomes a simple resource broker.

Naturally, gproc:await/1 works on global as well as on local names.

Something went wrong with that request. Please try again.