Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

strmod::unievent::Dispatcher Class Reference

An interface for a simple queuer and dispatcher of events. More...

#include <UniEvent/Dispatcher.h>

Inheritance diagram for strmod::unievent::Dispatcher:

Inheritance graph
[legend]
List of all members.

Public Methods

 Dispatcher ()
 Because every class (even abstract ones) should have a constructor.

virtual ~Dispatcher ()
 Because abstract classes should have a virtual destructor.

virtual int AreYouA (const lcore::ClassIdent &cid) const
 Asks if a class is of a particular type, or publicly derived from that type.

virtual void addEvent (const EventPtr &ev)=0
 Add an event to the queue.

virtual void addBusyPollEvent (const EventPtr &ev)=0
 Add an event that will be posted to poll something if the queue is busy.

virtual bool onQueueEmpty (const EventPtr &ev)=0
 This event is only triggered whenever an event dispatch is attempted when there's an empty queue.

virtual bool onInterrupt (const EventPtr &ev)=0
 This event is only triggered when interrupt() is called.

void dispatchEvent (Dispatcher *enclosing=0)
 Dispatch a single event.

virtual void dispatchEvents (unsigned int numevents, Dispatcher *enclosing=0)=0
 Dispatch until a certain number of events have been dispatched, or the queue is empty.

virtual void dispatchUntilEmpty (Dispatcher *enclosing=0)=0
 Dispatch until the queue is empty.

virtual void interrupt ()=0
 Interrupts the dispatcher to execute a high priority event.

virtual void stopDispatching ()=0
 Cause the multiple event dispatch methods to halt before they normally would.

virtual bool isQueueEmpty () const=0
 Does the queue have any events in it?


Static Public Attributes

const UNEVT_ClassIdent identifier
 Globally unique identifier for this class.


Protected Methods

virtual const lcore::ClassIdent * i_GetIdent () const
 Returns the class identifier for the class the object actually is.


Detailed Description

An interface for a simple queuer and dispatcher of events.

This provides an interface for classes that want to implement a queue of Event objects that are removed from the queue in FIFO order and 'fired' by calling their triggerEvent methods.

Definition at line 45 of file Dispatcher.h.


Member Function Documentation

virtual void strmod::unievent::Dispatcher::addBusyPollEvent const EventPtr   ev [pure virtual]
 

Add an event that will be posted to poll something if the queue is busy.

The Dispatcher maintains the concept of external and internal events. External events are those posted by the addEvent function. Internal events are those posted in response to some internal condition.

When external events cause other external events to be added, busy loops can take over the system. In order to prevent this, an event from this queue will be posted if the queue contains only external events.

Events in this queue should query some outside event source for events and use addEvent to add any there may be. Under no circumstance should one of these events always cause events to be added through addEvent. Doing this would just propogate the bad busy loop behavior.

Implemented in strmod::unievent::SimpleDispatcher.

int strmod::unievent::Dispatcher::AreYouA const lcore::ClassIdent &    cid const [inline, virtual]
 

Asks if a class is of a particular type, or publicly derived from that type.

Overriden in every derived class (with a static identifier member) to compare against the identifier, then call the AreYouA methods of all the superclasses.

Parameters:
cid Usually <class>::identifier for the class you want to ask if the object is an instance of.

Reimplemented from strmod::lcore::Protocol.

Reimplemented in strmod::unievent::SimpleDispatcher.

Definition at line 150 of file Dispatcher.h.

virtual const lcore::ClassIdent* strmod::unievent::Dispatcher::i_GetIdent   const [inline, protected, virtual]
 

Returns the class identifier for the class the object actually is.

Should always be overridden in any class that has a static identifier member.

Reimplemented from strmod::lcore::Protocol.

Reimplemented in strmod::unievent::SimpleDispatcher.

Definition at line 139 of file Dispatcher.h.

virtual void strmod::unievent::Dispatcher::interrupt   [pure virtual]
 

Interrupts the dispatcher to execute a high priority event.

This sets a flag so that as soon as the Dispatcher's event loop gets control, the event set by onInterrupt() will be put on the front of the queue. It will also call the Event::interrupt() method of any currently executing event.

Note:
Implementations of this method should be safe to call from a thread or a signal handling context.

Implemented in strmod::unievent::SimpleDispatcher.

virtual bool strmod::unievent::Dispatcher::onInterrupt const EventPtr   ev [pure virtual]
 

This event is only triggered when interrupt() is called.

When interrupt() is called, a flag is set so this event is put onto the front of the queue as soon as the Dispatcher's event loop gets control again.

Parameters:
ev The event to fire when interrupt() is called.
Returns:
true if the event was successfully set, false if the event was not set because some other event was already set.

Implemented in strmod::unievent::SimpleDispatcher.

virtual bool strmod::unievent::Dispatcher::onQueueEmpty const EventPtr   ev [pure virtual]
 

This event is only triggered whenever an event dispatch is attempted when there's an empty queue.

Parameters:
ev The event to fire when the queue is empty.
Returns:
true if the event was successfully set, false if the event was not set because some other event was already set.

Implemented in strmod::unievent::SimpleDispatcher.


Member Data Documentation

const UNEVT_ClassIdent strmod::unievent::Dispatcher::identifier [static]
 

Globally unique identifier for this class.

Every class that might need to be identified should have a public static const identifier object in it.

Reimplemented from strmod::lcore::Protocol.

Reimplemented in strmod::unievent::SimpleDispatcher.


The documentation for this class was generated from the following files:
Generated on Wed Jan 29 00:32:57 2003 for libNet by doxygen1.3-rc1