CEventPump Prototype
The event pump keeps a queue of pending events, processing them on-demand.
Syntax
var object = new CEventPump(eventsPerStep);
Arguments
Argument | Summary |
---|---|
eventsPerStep |
Remarks
You should never need to create an instance of this prototype; access the event pump through client.eventPump. Most code should only need to use the addHook, getHook and removeHookByName methods.
Members
Member | Summary |
---|---|
addBulkEvent | |
addEvent | |
addHook | Adds an event hook to be called when matching events are processed. |
getHook | Finds and returns data about a named event hook. |
onHook | |
removeHookByIndex | |
removeHookByName | Removes an existing event hook by its name. |
routeEvent | |
stepEvents |
See Also
Source Code
function CEventPump (eventsPerStep)
{
/* event routing stops after this many levels, safety valve */
this.MAX_EVENT_DEPTH = 50;
/* When there are this many 'used' items in a queue, always clean up. At
* this point it is MUCH more effecient to remove a block than a single
* item (i.e. removing 1000 is much much faster than removing 1 item 1000
* times [1]).
*/
this.FORCE_CLEANUP_PTR = 1000;
/* If there are less than this many items in a queue, clean up. This keeps
* the queue empty normally, and is not that ineffecient [1].
*/
this.MAX_AUTO_CLEANUP_LEN = 100;
this.eventsPerStep = eventsPerStep;
this.queue = new Array();
this.queuePointer = 0;
this.bulkQueue = new Array();
this.bulkQueuePointer = 0;
this.hooks = new Array();
/* [1] The delay when removing items from an array (with unshift or splice,
* and probably most operations) is NOT perportional to the number of items
* being removed, instead it is proportional to the number of items LEFT.
* Because of this, it is better to only remove small numbers of items when
* the queue is small (MAX_AUTO_CLEANUP_LEN), and when it is large remove
* only large chunks at a time (FORCE_CLEANUP_PTR), reducing the number of
* resizes being done.
*/
}