GNE  0.75.0
GNE::ConnectionEventGenerator Class Reference

A class used internally by GNE to generate the events in Connection. More...

#include <ConnectionEventGenerator.h>

Inheritance diagram for GNE::ConnectionEventGenerator:
GNE::Thread

Public Types

typedef SmartPtr
< ConnectionEventGenerator
sptr
typedef WeakPtr
< ConnectionEventGenerator
wptr
- Public Types inherited from GNE::Thread
enum  ThreadType {
  USER, TIMER, SYSTEM, CONNECTION,
  ALL
}
 An enum for specifying the thread type. More...
typedef SmartPtr< Threadsptr
typedef WeakPtr< Threadwptr

Public Member Functions

void reg (NLsocket socket, const SmartPtr< ReceiveEventListener > &listener)
 Register a socket to receive events generated by this class.
void unreg (NLsocket socket)
 Removes a socket.
void shutDown ()
 Tells the event generator to shutdown.
- Public Member Functions inherited from GNE::Thread
 Thread (std::string name=DEF_NAME, int priority=DEF_PRI)
 Creates a new thread, ready to run but not yet running.
std::string getName () const
 Returns the name of this thread.
void join ()
 A blocking call that returns when this thread terminates, or returns immediately if the thread has terminated.
bool hasStarted () const
 Returns true if this Thread has ever been started.
bool isRunning () const
 Determine the running state of the thread.
void start ()
 Starts this thread running.
int getPriority () const
 Returns the priority of this class.

Static Public Member Functions

static sptr create ()
 Creates a new instance of a ConnectionEventGenerator managed by a SmartPtr.
- Static Public Member Functions inherited from GNE::Thread
static sptr currentThread ()
 Returns the Thread object that represents this calling thread.
static void sleep (int ms)
 The currently running thread sleeps for the time given in milliseconds.
static void yield ()
 Makes a request to the operating system to give up the remainder of this thread's timeslice to another appropriate thread.
static bool waitForAllThreads (int ms)
 This method will wait for all threads that have a type != SYSTEM.
static void requestAllShutdown (ThreadType threadType)
 Calls the shutDown method of all running threads of the given type.

Protected Member Functions

void run ()
 The thread that listens for events.
- Protected Member Functions inherited from GNE::Thread
void setThisPointer (const wptr &thisPtr)
 IMPORTANT: call this method in your static create function.
sptr getThisPointer () const
 Returns a SmartPtr to this object.
void setType (ThreadType newType)
 Sets this Thread's type.

Additional Inherited Members

- Static Public Attributes inherited from GNE::Thread
static const int DEF_PRI = 0
 The default priority of a thread.
static const std::string DEF_NAME = "Thread"
 The default name for a thread.
static const int LOW_PRI = -1
 A lowered priority for a thread.
static const int LOWER_PRI = -2
 A lower priority for a thread than LOW_PRI.
static const int HIGH_PRI = 1
 A "boosted priority" for a thread.
static const int HIGHER_PRI = 2
 Even higher priority thread than HIGH_PRI.
- Protected Attributes inherited from GNE::Thread
volatile bool shutdown
 This variable is set to true when this thread should exit.

Detailed Description

A class used internally by GNE to generate the events in Connection.

Users of GNE should not need to use or know about this class. This class uses nlPollGroup to check for events comming in on sockets.

Member Function Documentation

void GNE::ConnectionEventGenerator::reg ( NLsocket  socket,
const SmartPtr< ReceiveEventListener > &  listener 
)

Register a socket to receive events generated by this class.

If the socket is already registered then this method has no effect (even if the registered listener is NOT the one passed!)

Parameters
socketthe low-level HawkNL socket for this connection.
connthe Connection class associated with the socket.
void GNE::ConnectionEventGenerator::run ( )
protectedvirtual

The thread that listens for events.

Bug:
If nlPollGroup fails, the error is not reported. Instead the results are ignored, and the call is made again (or in debug mode, the assert fails).

Implements GNE::Thread.

void GNE::ConnectionEventGenerator::shutDown ( )
virtual

Tells the event generator to shutdown.

This function is called internally on library cleanup, so you should not call it.

Reimplemented from GNE::Thread.

void GNE::ConnectionEventGenerator::unreg ( NLsocket  socket)

Removes a socket.

If the socket is not registered, then no action takes place. This method will not block to wait for the unregistration to take place.

Parameters
socketthe low-level HawkNL socket for this connection.

The documentation for this class was generated from the following files: