Main Page   Modules   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members   Related Pages  

GNE::EventThread Class Reference
[Internal Classes]

#include <EventThread.h>

Inheritance diagram for GNE::EventThread:

GNE::Thread List of all members.

Public Types

typedef SmartPtr< EventThread > sptr
typedef WeakPtr< EventThread > wptr

Public Member Functions

SmartPtr< ConnectionListenergetListener () const
 Use GNE::Connection::getListener.

void setListener (const SmartPtr< ConnectionListener > &listener)
 Use GNE::Connection::setListener.

int getTimeout () const
 Use GNE::Connection::getTimeout.

void setTimeout (int ms)
 Use GNE::Connection::setTimeout.

void onDisconnect ()
 For more information about these events, see ConnectionListener.

void onExit ()
 For more information about these events, see ConnectionListener.

void onFailure (const Error &error)
 For more information about these events, see ConnectionListener.

void onError (const Error &error)
 For more information about these events, see ConnectionListener.

void onReceive ()
 For more information about these events, see ConnectionListener.

void shutDown ()
 Overrides Thread::shutDown so that the daemon thread will be woken up since it might be waiting on a ConditionVariable.


Static Public Member Functions

sptr create (const SmartPtr< Connection > &conn)
 Initializes this class as a event thread for a listener.


Protected Member Functions

 EventThread (const SmartPtr< Connection > &conn)
void run ()
 This thread serializes events for a Connection.


Detailed Description

Internal class used by GNE to manage Connection events.

Each Connection has an EventThread. This is used internally by the Connection class to act as a proxy to dispatch events to the ConnectionListener. Because of this, only one event per Connection will be active at any one time. Another appropriate name that might describe this would be an EventQueue. But to improve efficency and stability, some events may be reordered or combined. Remember that onReceive means 1 or more packets have been received. If multiple onReceive or onDoneWriting occur, they will probably be combined. Error events will always have first priority, and if the error leads to a disconnect, pending events after that will not be called (except for onDisconnect).

EventThread was created to solve several things:


Constructor & Destructor Documentation

GNE::EventThread::EventThread const SmartPtr< Connection > &  conn  )  [protected]
 

See also:
create


Member Function Documentation

sptr GNE::EventThread::create const SmartPtr< Connection > &  conn  )  [static]
 

Initializes this class as a event thread for a listener.

The conn pointer is used to call disconnect when an onFailure event is finally processed. This is to assure that disconnect is called from a safe thread that won't lead to deadlock when a failure occurs.

The SmartPtr also keeps the Connection alive if it is still active.

void GNE::EventThread::onDisconnect  ) 
 

For more information about these events, see ConnectionListener.

The processing of an onDisconnect event will be the last, and the thread will essentially stop when onDisconnect completes.

void GNE::EventThread::shutDown  )  [virtual]
 

Overrides Thread::shutDown so that the daemon thread will be woken up since it might be waiting on a ConditionVariable.

Once it shuts down it should not be activated again.

Reimplemented from GNE::Thread.


The documentation for this class was generated from the following files:
Generated on Fri Aug 22 13:40:06 2003 for GNE by doxygen1.3