Cascading Behaviours
From Erlang Community
Contents |
Author
Vance Shipley
Introduction
Behaviours
Behaviour modules encapsulate some certain functionality for reuse by other modules. The definition of a behaviour includes not only it's exported functions but a list of functions which a callback module must implement. OTP includes several behaviour modules with the most common being gen_server and gen_fsm.
Using gen_fsm
Behaviour
To declare your module as a behaviour callback module you include the -behaviour attribute.
Code listing 2.1: Behaviour Attribute |
-behaviour(gen_fsm). |
Note: All this really does is to enable compilation time checking that you have exported the required callbacks. |
Exports
A module which uses the gen_fsm behaviour must export the callbacks which the gen_fsm module calls to handle events. These include handlers for common gen_fsm events as well as the handlers for your user defined states.

Digg It
Del.icio.us
Reddit
Facebook
Stumble Upon
Technorati

