Erlang Central

Cascading Behaviours

Revision as of 11:46, 15 June 2007 by DriscollLentz949 (Talk | contribs)

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




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


To declare your module as a behaviour callback module you include the -behaviour attribute.


Note: All this really does is to enable compilation time checking that you have exported the required callbacks.


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


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.