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

strmod::unievent::SimpleDispatcher Class Reference

A class that does the minimum necessary to support the Dispatcher interface. More...

#include <UniEvent/SimpleDispatcher.h>

Inheritance diagram for strmod::unievent::SimpleDispatcher:

Inheritance graph
[legend]
List of all members.

Public Methods

 SimpleDispatcher ()
 Create one.

virtual ~SimpleDispatcher ()
 Destroy one.

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)
 Add an event to the queue.

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

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

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

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

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

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

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

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


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

A class that does the minimum necessary to support the Dispatcher interface.

Definition at line 41 of file SimpleDispatcher.h.


Member Function Documentation

void strmod::unievent::SimpleDispatcher::addBusyPollEvent const EventPtr   ev [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.

Implements strmod::unievent::Dispatcher.

Definition at line 135 of file SimpleDispatcherImp.cxx.

int strmod::unievent::SimpleDispatcher::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::unievent::Dispatcher.

Definition at line 88 of file SimpleDispatcher.h.

virtual const lcore::ClassIdent* strmod::unievent::SimpleDispatcher::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::unievent::Dispatcher.

Definition at line 68 of file SimpleDispatcher.h.

void strmod::unievent::SimpleDispatcher::interrupt   [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.

Implements strmod::unievent::Dispatcher.

Definition at line 353 of file SimpleDispatcherImp.cxx.

bool strmod::unievent::SimpleDispatcher::onInterrupt const EventPtr   ev [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.

Implements strmod::unievent::Dispatcher.

Definition at line 337 of file SimpleDispatcherImp.cxx.

bool strmod::unievent::SimpleDispatcher::onQueueEmpty const EventPtr   ev [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.

Implements strmod::unievent::Dispatcher.

Definition at line 324 of file SimpleDispatcherImp.cxx.


Member Data Documentation

const UNEVT_ClassIdent strmod::unievent::SimpleDispatcher::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::unievent::Dispatcher.


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