Chapter 11. More on Multiprocessing

The examples shown in Chapter 10 were suitable for demonstrative purposes, but they won’t take you very far in your own projects. It’s not that the examples were bad; it’s just that there’s no huge advantage to processes and actors if they’re just functions with messages. To reap the benefits, we need to be able to hold state in a process.

In this chapter, we will apply the concurrency concepts and primitives to practical examples that are able to hold state.

State Your State

Let’s first create a function in a new kitchen.erl module that will let a process act like a refrigerator. The process will allow two operations: storing food in the fridge and taking food from the fridge. It should only be possible to take ...

Get Learn You Some Erlang for Great Good! now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.