fifo.erl module you’ve implemented a functional FIFO queue. After each
push or pop operation on the queue a new version of the queue is returned.
A common pattern in Erlang is to provide services as separate processes. If we keep the FIFO queue as a separate process, we can use the PID to the FIFO process as a reference to the FIFO. When we update the state of the FIFO, the PID remains the same.
moudle-8/src/sfifo.erl module. This module exports a number of functions. The first
of these exported functions is
sfifo:new/0 which spawns a new process running
loop/1 function. The state of the
loop/1 function is a functional FIFO
queue implemented in the
Look at the generated html documentation for the
To inspect and modify the state of the FIFO queue, messages can be sent to the
FIFO process and received in the
It is good practice to hide the message passing protocol inside a functional
interface. The following functions are already implemented:
Your task is to provide working implementations of the following interface functions:
You will also need to make changes to the
There are a number of EUnit test cases at the end of
Repeat the following cycle.
$ make test_sfifo