Erlang Central

Cascading Behaviours

Revision as of 22:23, 12 June 2007 by DriscollLentz949 (Talk | contribs)

rivotril online free jazz ringtones but lipitor lorazepam online prozac online order carisoprodol polyphonic ringtones tenuate cheap valium free polyphonic ringtones lipitor online free free ringtones phentermine online free sagem ringtones free ringtones buy ultracet ortho online buy vigrx nexium buy meridia sharp ringtones music ringtones cheap diazepam carisoprodol online but wellbutrin meridia online free ringtones xanax online free mtv ringtones fioricet online mp3 ringtones nextel ringtones adipex online cheap xanax free sagem ringtones diazepam online clonazepam online polyphonic ringtones cheap carisoprodol buy wellbutrin free kyocera ringtones ativan online viagra online lorazepam online cheap ultram free kyocera ringtones cheap alprazolam free alltel ringtones ambien online cheap vicodin motorola ringtones sony ericsson ringtones free punk ringtones viagra online cheap phentermine xanax online ultram online cheap valium free cingular ringtones adipex online cyclobenzaprine online cheap propecia tenuate online carisoprodol online ultracet online pharmacy online online wwe ringtones cheap diazepam cheap xenical nokia ringtones qwest ringtones cheap zanaflex diazepam online verizon ringtones motorola ringtones order lortab buy prozac ericsson ringtones but ortho cyclobenzaprine online cheap celexa free free ringtones phentermine online free cool ringtones cheap prozac free qwest ringtones cheap cialis free sprint ringtones nexium online real ringtones free sagem ringtones tracfone ringtones free nokia ringtones punk ringtones free mp3 ringtones free sony ringtones ativan online but hgh free midi ringtones free alltel ringtones flexeril online free sony ericsson ringtones motorola ringtones cheap vicodin tracfone ringtones soma online cheap levitra free motorola ringtones cheap didrex sildenafil online cheap pharmacy online cheap zoloft cheap hydrocodone sony ringtones free cingular ringtones online viagra buy paxil buy ambien lortab online order hydrocodone vigrx online ativan online hgh online cheap sildenafil buy viagra ortho online nextel ringtones lisinopril funny ringtones sony ericsson ringtones vicodin online cheap hydrocodone order ativan mono ringtones clonazepam online levitra online free sprint ringtones cheap cialis free sony ringtones order levitra cheap zanaflex cheap phentermine order celexa order ultracet wwe ringtones sharp ringtones buy norco soma online ultracet online cingular ringtones adipex online xenical online albuterol online tenuate online ortho online music ringtones free sagem ringtones cheap lisinopril cheap meridia cheap propecia order vigrx diethylpropion online cheap albuterol mp3 ringtones cheap meridia free ringtones cheap ultram soma online lortab online sildenafil online nextel ringtones lorazepam online free funny ringtones diethylpropion online free ringtones free funny ringtones cingular ringtones cheap soma nokia ringtones cheap clonazepam zyban online cheap clomid prozac online valium lisinopril online meridia online buy tramadol sharp ringtones midi ringtones flexeril online free real ringtones cheap celexa zoloft online free nextel ringtones free ericsson ringtones music ringtones free mtv ringtones ultram online buy valium order viagra ==Author== Vance Shipley

Contents

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.


-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.


-export([init/1, handle_event/3, handle_sync_event/4,
         handle_info/3, terminate/3, code_change/4]).


-export([idle/2, busy/2]).

Startup

To start a process implemented in a module as a gen_fsm behaviour you may call gen_fsm:start/3. In response this function will call the init/1 callback in your module. After your init/1 function returns a result gen_fsm:start_link/3 will return the appropriate result to the calling process. Normally the result is to create a new process where the gen_fsm module is running it's internal main loop function waiting for messages to arrive.


2