EpcTools
An event based multi-threaded C++ development framework.
Public Member Functions | Friends | List of all members
ESocket::Thread< TQueue, TMessage > Class Template Reference

The socket thread base class. An event based thread class capable of surfacing socket events. More...

#include <esocket.h>

Inheritance diagram for ESocket::Thread< TQueue, TMessage >:
EThreadEvent< TQueue, TMessage > EThreadBasic _EThreadEventBase

Public Member Functions

 Thread ()
 Default constructor. More...
 
virtual ~Thread ()
 Class destructor. More...
 
Void registerSocket (Base< TQueue, TMessage > *socket)
 Called by the framework to register a Base derived socket object with this thread. More...
 
Void unregisterSocket (Base< TQueue, TMessage > *socket)
 Called by the framework to unregister a Base derived socket object with this thread. More...
 
Int getError ()
 Called when an error is detected. More...
 
- Public Member Functions inherited from EThreadEvent< TQueue, TMessage >
 EThreadEvent ()
 Default class constructor. More...
 
 ~EThreadEvent ()
 Rhe class destructor. More...
 
Bool sendMessage (UInt message, Bool wait=True)
 Sends event message to this thread. More...
 
Bool sendMessage (UInt message, pVoid voidptr, Bool wait=True)
 Sends event message to this thread. More...
 
Bool sendMessage (const TMessage &msg, Bool wait=True)
 Sends event message to this thread. More...
 
virtual Void init (Short appId, UShort threadId, pVoid arg, Int queueSize=16384, Bool suspended=False, Dword stackSize=0)
 Initializes the thread object. More...
 
Void quit ()
 Posts the quit message to this thread. More...
 
Void start ()
 Initializes the thread when it was suspended at init(). More...
 
Void suspend ()
 Suspends a running thread. More...
 
Void resume ()
 Resumes a suspended thread. More...
 
virtual Void onInit ()
 Called in the context of the thread when the EM_INIT event is processed. More...
 
virtual Void onQuit ()
 Called in the context of the thread when the EM_QUIT event is processed. More...
 
virtual Void onSuspend ()
 Called in the context of the thread when th EM_SUSPEND event is processed. More...
 
virtual Void onTimer (EThreadEventTimer *ptimer)
 Called in the context of the thread when th EM_TIMER event is processed. More...
 
Void initTimer (EThreadEventTimer &t)
 Intializes an EThreadEvent::Timer object and associates with this thread. More...
 
ESemaphoreDatagetMsgSemaphore ()
 Returns the semaphore associated with this thread's event queue. More...
 
- Public Member Functions inherited from EThreadBasic
 EThreadBasic ()
 Class constructor. More...
 
virtual ~EThreadBasic ()
 Class destructor. More...
 
Void init (pVoid arg, size_t stackSize=0)
 Initialize and start the thread. More...
 
Void join ()
 Waits for the thread to terminate. More...
 
Bool isInitialized ()
 Returns the thread initialization state. More...
 
RunState getRunState ()
 Returns the current thread run state. More...
 
Bool isWaitingToRun ()
 Determines if the thread is waiting to run. More...
 
Bool isRunning ()
 Determines if the thread is running. More...
 
Bool isDoneRunning ()
 Determines if the thread has finished running. More...
 
Int cancelWait ()
 Sends a cancellation request to the thread. More...
 
Void signal (Int sig)
 

Friends

class TCP::Talker< TQueue, TMessage >
 
class TCP::Listener< TQueue, TMessage >
 
class UDP< TQueue, TMessage >
 

Additional Inherited Members

- Public Types inherited from EThreadBasic
enum  RunState { rsWaitingToRun, rsRunning, rsDoneRunning }
 EThreadBasic run states. More...
 
- Static Public Member Functions inherited from EThreadBasic
static Void sleep (Int milliseconds)
 Sleeps for the specified number of milliseconds. More...
 
static Void yield ()
 Relinquishes the CPU. More...
 
- Protected Member Functions inherited from EThreadEvent< TQueue, TMessage >
virtual Void messageQueued ()
 Called when an event message is queued. More...
 
Bool pumpMessage (TMessage &msg, Bool wait=true)
 Dispatches the next thread event message. More...
 
virtual Void pumpMessages ()
 Process event messages. More...
 
virtual Void defaultMessageHandler (TMessage &msg)
 The default event message handler. More...
 
pid_t getThreadId ()
 Retrieves the internal thread ID. More...
 
- Static Protected Member Functions inherited from EThreadBasic
static Void Initialize ()
 performs internal initialization *** DO NOT CALL *** More...
 
static Void UnInitialize ()
 performs internal de-initialization *** DO NOT CALL *** More...
 

Detailed Description

template<class TQueue, class TMessage>
class ESocket::Thread< TQueue, TMessage >

The socket thread base class. An event based thread class capable of surfacing socket events.

Constructor & Destructor Documentation

◆ Thread()

template<class TQueue, class TMessage>
ESocket::Thread< TQueue, TMessage >::Thread ( )
inline

Default constructor.

◆ ~Thread()

template<class TQueue, class TMessage>
virtual ESocket::Thread< TQueue, TMessage >::~Thread ( )
inlinevirtual

Class destructor.

Member Function Documentation

◆ getError()

template<class TQueue, class TMessage>
Int ESocket::Thread< TQueue, TMessage >::getError ( )
inline

Called when an error is detected.

◆ registerSocket()

template<class TQueue, class TMessage>
Void ESocket::Thread< TQueue, TMessage >::registerSocket ( Base< TQueue, TMessage > *  socket)
inline

Called by the framework to register a Base derived socket object with this thread.

Parameters
socketthe socket to register.

◆ unregisterSocket()

template<class TQueue, class TMessage>
Void ESocket::Thread< TQueue, TMessage >::unregisterSocket ( Base< TQueue, TMessage > *  socket)
inline

Called by the framework to unregister a Base derived socket object with this thread.

Parameters
socketthe socket to unregister.

Friends And Related Function Documentation

◆ TCP::Listener< TQueue, TMessage >

template<class TQueue, class TMessage>
friend class TCP::Listener< TQueue, TMessage >
friend

◆ TCP::Talker< TQueue, TMessage >

template<class TQueue, class TMessage>
friend class TCP::Talker< TQueue, TMessage >
friend

◆ UDP< TQueue, TMessage >

template<class TQueue, class TMessage>
friend class UDP< TQueue, TMessage >
friend

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