![]() |
µGFX
2.9
version 2.9
|
Module to build a complete many-to-many event system.
GEVENT provides a simple to use but yet powerful event system.
Functions | |
void | geventListenerInit (GListener *pl) |
Create a Listener. More... | |
gBool | geventAttachSource (GListener *pl, GSourceHandle gsh, gU32 flags) |
Attach a source to a listener. More... | |
void | geventDetachSource (GListener *pl, GSourceHandle gsh) |
Detach a source from a listener. More... | |
GEvent * | geventEventWait (GListener *pl, gDelay timeout) |
Wait for an event on a listener from an assigned source. More... | |
void | geventEventComplete (GListener *pl) |
Release the GEvent buffer associated with a listener. More... | |
GSourceListener * | geventGetSourceListener (GSourceHandle gsh, GSourceListener *lastlr) |
Called by a source with a possible event to get a listener record. More... | |
GEvent * | geventGetEventBuffer (GSourceListener *psl) |
Get the event buffer from the GSourceListener. More... | |
void | geventSendEvent (GSourceListener *psl) |
Called by a source to indicate the listener's event buffer has been filled. More... | |
void | geventDetachSourceListeners (GSourceHandle gsh) |
Detach any listener that has this source attached. More... | |
GEVENT Functionality to be included | |
#define | GEVENT_ASSERT_NO_RESOURCE GFXOFF |
Should routines assert() if they run out of resources. More... | |
GEVENT Optional Sizing Parameters | |
#define | GEVENT_MAXIMUM_SIZE 32 |
Defines the maximum size of an event status variable. More... | |
#define | GEVENT_MAX_SOURCE_LISTENERS 32 |
Defines the maximum Source/Listener pairs in the system. More... | |
gBool geventAttachSource | ( | GListener * | pl, |
GSourceHandle | gsh, | ||
gU32 | flags | ||
) |
Attach a source to a listener.
Flags are interpreted by the source when generating events for each listener. If this source is already assigned to the listener it will update the flags. If insufficient resources are available it will either assert or return gFalse depending on the value of GEVENT_ASSERT_NO_RESOURCE.
[in] | pl | The listener |
[in] | gsh | The source which has to be attached to the listener |
[in] | flags | The flags |
void geventDetachSource | ( | GListener * | pl, |
GSourceHandle | gsh | ||
) |
void geventDetachSourceListeners | ( | GSourceHandle | gsh | ) |
Detach any listener that has this source attached.
[in] | gsh | The source handle |
Definition at line 220 of file gevent.c.
References gfxMutexEnter(), and gfxMutexExit().
void geventEventComplete | ( | GListener * | pl | ) |
Release the GEvent buffer associated with a listener.
The GEvent returned by geventEventWait()
is released.
geventEventWait()
is released when geventEventWait()
is called again or when this function is called. The GEvent object MUST NOT be used after this function is called.[in] | pl | The listener |
GEvent* geventEventWait | ( | GListener * | pl, |
gDelay | timeout | ||
) |
Wait for an event on a listener from an assigned source.
The type of the event should be checked (pevent->type) and then pevent should be typecast to the actual event type if it needs to be processed. gDelayForever means no timeout - wait forever for an event. gDelayNone means return immediately
geventEventComplete()
is called. Calling geventEventComplete()
allows the GEvent object to be reused earlier which can reduce missed events. The GEvent object MUST NOT be used after this function is called (and is blocked waiting for the next event) or after geventEventComplete() is called. The one listener object should not be waited on using more than one thread simultanously because of the implicit geventEventComplete() that occurs when this function is called.[in] | pl | The listener |
[in] | timeout | The timeout in milliseconds |
GEvent* geventGetEventBuffer | ( | GSourceListener * | psl | ) |
Get the event buffer from the GSourceListener.
A NULL return allows the source to record (perhaps in glr->scrflags) that the listener has missed events. This can then be notified as part of the next event for the listener. The buffer can only be accessed untill the next call to geventGetSourceListener()
or geventSendEvent()
[in] | psl | The source listener |
Definition at line 187 of file gevent.c.
References gfxMutexEnter(), and gfxMutexExit().
GSourceListener* geventGetSourceListener | ( | GSourceHandle | gsh, |
GSourceListener * | lastlr | ||
) |
Called by a source with a possible event to get a listener record.
lastlr
should be NULL on the first call and thereafter the result of the previous call.
[in] | gsh | The source handler |
[in] | lastlr | The source listener |
Definition at line 163 of file gevent.c.
References GEVENT_MAX_SOURCE_LISTENERS, gfxMutexEnter(), and gfxMutexExit().
void geventListenerInit | ( | GListener * | pl | ) |
void geventSendEvent | ( | GSourceListener * | psl | ) |
Called by a source to indicate the listener's event buffer has been filled.
After calling this function the source must not reference in fields in the GSourceListener
or the event buffer.
[in] | psl | The source listener |
Definition at line 200 of file gevent.c.
References gfxMutexEnter(), gfxMutexExit(), and gfxSemSignal().
#define GEVENT_ASSERT_NO_RESOURCE GFXOFF |
Should routines assert() if they run out of resources.
Defaults to GFXOFF.
If GFXOFF the application must be prepared to handle these failures.
Definition at line 30 of file gevent_options.h.
#define GEVENT_MAX_SOURCE_LISTENERS 32 |
Defines the maximum Source/Listener pairs in the system.
Defaults to 32
Definition at line 50 of file gevent_options.h.
#define GEVENT_MAXIMUM_SIZE 32 |
Defines the maximum size of an event status variable.
Defaults to 32 bytes
Definition at line 43 of file gevent_options.h.