GNE
0.75.0
|
A class used internally by GNE to generate the events in Connection. More...
#include <ConnectionEventGenerator.h>
Public Types | |
typedef SmartPtr < ConnectionEventGenerator > | sptr |
typedef WeakPtr < ConnectionEventGenerator > | wptr |
![]() | |
enum | ThreadType { USER, TIMER, SYSTEM, CONNECTION, ALL } |
An enum for specifying the thread type. More... | |
typedef SmartPtr< Thread > | sptr |
typedef WeakPtr< Thread > | wptr |
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. | |
![]() | |
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 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. | |
![]() | |
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 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. | |
![]() | |
volatile bool | shutdown |
This variable is set to true when this thread should exit. |
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.
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!)
socket | the low-level HawkNL socket for this connection. |
conn | the Connection class associated with the socket. |
|
protectedvirtual |
The thread that listens for events.
Implements GNE::Thread.
|
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.
socket | the low-level HawkNL socket for this connection. |