let me know the concept of gen_event behaviour

Vance Shipley <>
Mon Feb 10 22:03:17 CET 2003


The gen_event behaviour is best used for doing things like handling
alarms or other system messages.  You implement an event manager using
this behaviour which all of your management messages are sent to.  
You then install event handlers for each message type which you are
interested in.  An example would be an event manager which received 
messages like {disk, over_90_percent}, {disk, under_90_percent}, 
{cpu,  over_90_percent}, etc.  You might have a disk handler and a 
cpu handler.  You might also install a short lived handler which was 
also interested in cpu usage.  This handler might be used to wait 
until the cpu usage was below threshold and then remove itself and 
run some task.  Your handlers act on the messages they are interested 
in and ignore (do nothing) with other messages.  Your short lived task
would react to the cpu messages and the normal cpu handler would also
do it's thing.

The key point to understand is that _every_ event handler is called for
_every_ event.  This being the case you probably don't want to have
1000 handlers.  

Please also understand that there is only one process here, that being
the event manager.  The event handler callbacks are run within the 
same process.

If I didn't address you questions directly it is because I didn't 
quite understand them.


On Mon, Feb 10, 2003 at 04:43:15PM +0000, Suresh S wrote:
}  Hi,
}  There is an Event manager can add Event handlers, This event handlers will handle particular event,
}  Is every  Event is a Call back module ? if so  suppose there are 1000 calls processing in the applicaiton at once, then 1000 call events are generated, then if we use gen_event behaviour there will be 1000 call back modules active( generated )
}  Please clarify this, let me know the concept of gen_event behaviours  
}  Thanking u in advance.
}  regards
}  Suresh S

More information about the erlang-questions mailing list