Home > DeveloperSection > Interviews > Types of module behaviours in Erlang?

Posted on    March-05-2016 6:12 AM

 erlang Concurrent Programming  erlang 
 1 Answer(s)
  434  View(s)
Rate this:

Tarun Kumar

Total Post:107

Posted on    March-05-2016 7:12 AM

Behaviours are like patterns which makes easier to understand the erlang code to every Erlang programmer. The idea behind the Behaviour is to divide the Erlang code for a process in a generic part (means: a behaviour module) and a callback module.

There are different types of behaviours in Erlang, some of them are as follows:
1. gen_server: gen_server allows to send and receive sync and async messages, start and stop processes and allows to code change.
2. gen_event: gen_event is used for implementing event handling functionality and the OTP event handling model consists of a generic event manager process with an arbitrary number of event handlers that are added and deleted dynamically.
3. supervisor: supervisor is used for monitoring processes and we can implement a good shutdown and restart strategy around it.
4. gen_fsm: gen_fsm allows changes whether there are too many states involve in an application.
5. gen_mod: gen_mod provides the facility to extend the ejabberd modules with the xmpp server have to implement gen_mod behaviour. And also it has start/2 and stop/1 functions that allows us to intergrate the custom functions of our module. 

Modified On Mar-05-2016 06:24:41 AM

Don't want to miss updates? Please click the below button!

Follow MindStick