O'Reilly logo

Functional Web Development with Elixir, OTP, and Phoenix by Lance Halvorsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Naming GenServer Processes

This whole chapter we’ve been starting new GenServer processes and binding their PIDs to variables. Whenever we’ve needed to call a public function on a process, we’ve passed that variable in as the first argument. That clearly works, but it leaves us with a problem.

In a full application, we’d need to keep track of every variable for every process we started. We’d need to always keep them in scope, and we’d need to clear individual variables out when their process stopped. If that sounds really messy, it is.

It would be great if we could just name each process as we start it, and pass that name in whenever we wanted to call a function. It would be even better if we didn’t have to remember the name, but were able to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required