Event management
Compounds
struct eventstruct event_calloutstruct event_defTypedefs
Functions
void event_initialize (event *queue, unsigned short size)void event_add_callout (event_type type, event_callout *callout)void event_remove_callout (event_callout *callout)void event_register (event_type type, event_callout *callout, event_handler_t handler, void *client_data)void event_wait (unsigned long nticks, event_type type)Variables
Detailed Description
This module is a small event manager. It contains a queue of events and allows other modules to subscribe to a particular event type.Subscribing to an event means connecting a callout object to the event type. The callout contains a function which is called by the event manager when an event of the corresponding type is received. The callout object should be a static object. It should be registered only once with the event_register method.
Posting an event is an asynchronous operation which does not block. The event is marked with a time stamp and inserted in the event queue. The event is posted using the event_post function.
The event manager does not use threads to report events to its subscribers. It is necessary to call explicitly the event manager so that it dispatches the pending events.
Function Documentation
void event_add_callout ( event_type type,event_callout * callout)Register an event handler.
Register an handler to receive events of a given type.
Initialize the event package.
The event buffer queue is passed in 'queue' and it can contain up to 'size' events. Initialization should be done only once and before using any other event method.
- Parameters:
queue the event buffer queuesize the size in element of that buffer
- See also:
- event_post
void event_post ( event_type type,unsigned short data)Post an event.
An event of the specified type is queued at the end of the event queue. The event queue contains a fixed number of elements. It does not grow. If the event queue was full, the oldest event is forgotten. The event is marked with the free running timer counter. This operation is designed to be efficient and can be called from an interrupt handler. When the event is queued, the data parameter is saved with it. This value is not interpreted and can be used to pass some additional information related to the event itself.
Events are dispatched synchronously by `event_dispatch' which activates the handlers that were registered.
- See also:
- event_initialize, event_register, event_dispatch
void event_register ( event_type type,event_callout * callout,event_handler_t handler,void * client_data)[inline]Register an event handler.
Register an handler to receive events of a given type.
void event_remove_callout ( event_callout * callout )Remove an event callout.
Copyright (C) 1999, 2000, 2001, 2002, 2003 Stéphane Carrez, France
Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.