September 2013
Intermediate to advanced
548 pages
12h 25m
English
Making an OTP gen_server is largely a matter of filling
in a boilerplate template with some code of your own. The following is an
example; the individual sections of the gen_server were
listed in the previous section. The gen_server template itself is
built into Emacs, but if you’re not using Emacs, you can find the entire
template in The Generic Server Template.
I’ve filled in the template to make a bank module called
my_bank. This code is derived from the template. I’ve
removed all the comments from the template so you can clearly
see the structure of the code.
| my_bank.erl | |
| | -module(my_bank). |
| | |
| | -behaviour(gen_server). |
| | -export([start/0]). |
| | %% gen_server callbacks |
| | -export([init/1, handle_call/3, ... |
Read now
Unlock full access