Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

event.h File Reference

Functions for handling event triggers. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  event_t
 The structure which represents an event. More...

Defines

#define EVENT_ANY_SIGNAL   -1
 The signal number that is used to match any signal.
#define EVENT_ANY_PID   0
 The process id that is used to match any process id.

Enumerations

enum  {
  EVENT_ANY, EVENT_SIGNAL, EVENT_VARIABLE, EVENT_EXIT,
  EVENT_JOB_ID, EVENT_GENERIC
}
 Enumeration of event types. More...

Functions

void event_add_handler (event_t *event)
 Add an event handler.
void event_remove (event_t *event)
 Remove all events matching the specified criterion.
int event_get (event_t *criterion, array_list_t *out)
 Return all events which match the specified event class.
void event_fire (event_t *event)
 Fire the specified event.
void event_init ()
 Initialize the event-handling library.
void event_destroy ()
 Destroy the event-handling library.
void event_free (event_t *e)
 Free all memory used by the specified event.
const wchar_t * event_get_desc (event_t *e)
 Returns a string describing the specified event.
void event_fire_generic (const wchar_t *name)
 Fire a generic event with the specified name.


Detailed Description

Functions for handling event triggers.

Because most of these functions can be called by signal handler, it is important to make it well defined when these functions produce output or perform memory allocations, since such functions may not be safely called by signal handlers.


Enumeration Type Documentation

anonymous enum
 

Enumeration of event types.

Enumerator:
EVENT_ANY  Matches any event type (Not always any event, as the function name may limit the choice as well.
EVENT_SIGNAL  An event triggered by a signal.
EVENT_VARIABLE  An event triggered by a variable update.
EVENT_EXIT  An event triggered by a job or process exit.
EVENT_JOB_ID  An event triggered by a job exit.
EVENT_GENERIC  A generic event.


Function Documentation

void event_add_handler event_t event  ) 
 

Add an event handler.

May not be called by a signal handler, since it may allocate new memory.

void event_fire event_t event  ) 
 

Fire the specified event.

The function_name field of the event must be set to 0. If the event is of type EVENT_SIGNAL, no the event is queued, and will be dispatched the next time event_fire is called. If event is a null-pointer, all pending events are dispatched.

This function is safe to call from a signal handler _ONLY_ if the event parameter is for a signal. Signal events not be fired, by the call to event_fire, instead they will be fired the next time event_fire is called with anull argument. This is needed to make sure that no code evaluation is ever performed by a signal handler.

Parameters:
event the specific event whose handlers should fire. If null, then all delayed events will be fired.

int event_get event_t criterion,
array_list_t out
 

Return all events which match the specified event class.

This function is safe to call from a signal handler _ONLY_ if the out parameter is null.

Parameters:
criterion Is the class of events to return. If the criterion has a non-null function_name, only events which trigger the specified function will return.
out the list to add events to. May be 0, in which case no events will be added, but the result count will still be valid
Returns:
the number of found matches

const wchar_t* event_get_desc event_t e  ) 
 

Returns a string describing the specified event.

The string should not be freed.

void event_remove event_t event  ) 
 

Remove all events matching the specified criterion.

May not be called by a signal handler, since it may free allocated memory.


Generated on Sun Jan 13 02:52:44 2008 for fish by  doxygen 1.4.4