C++ common classes
General purpose classes for use across projects (Apache license)
|
CPHandler handles all the connections in a pool, adding, removing, etc. More...
#include <CPHandler.h>
Public Member Functions | |
CPHandler () | |
virtual | ~CPHandler () |
virtual BOOL | AddConnection (CPConnection *pConnections, SOCKET NewSocket=INVALID_SOCKET) |
Add a connection to handle. | |
virtual BOOL | RemoveConnection (CPConnection *pConnection) |
Remove a connection from our purview. | |
virtual int | GetLastSize () |
Get the last size (not necesssarily current) | |
virtual int | GetCurrentSize () |
Get the current size (will wait for critical seection) | |
virtual int | CallHandleConnection (CPConnection *pConnection) |
Protected Member Functions | |
virtual unsigned | WorkerFunction (void *pParam)=0 |
Function that does the work. | |
virtual void | CallDisconnected (CPConnection *pConnection) |
If we want to call the sockets Disconnected member. | |
virtual void | DisconnectAll () |
Called in the case of an unrecoverable error. | |
Protected Attributes | |
CXPlatCriticalSection | cCritMap |
To protect cLiveConnections. | |
CONNECTION_MAP | cLiveConnections |
Active connections. | |
CXPlatCriticalSection | cCritQueuedMap |
To protect cQueuedConnections. | |
CONNECTION_MAP | cQueuedConnections |
Will add to cLiveConnections at beginning of each I/O cycle. | |
int | iLiveSize |
# in cLiveConnections | |
int | iSize |
# in cLiveConnections + cQueuedConnections | |
BOOL | bThreadRunning |
Faster than querying the thread. |
CPHandler handles all the connections in a pool, adding, removing, etc.
Definition at line 35 of file CPHandler.h.
Definition at line 28 of file CPHandler.cpp.
CPHandler::~CPHandler | ( | ) | [virtual] |
Definition at line 38 of file CPHandler.cpp.
BOOL CPHandler::AddConnection | ( | CPConnection * | pConnections, |
SOCKET | NewSocket = INVALID_SOCKET |
||
) | [virtual] |
Add a connection to handle.
Definition at line 48 of file CPHandler.cpp.
void CPHandler::CallDisconnected | ( | CPConnection * | pConnection | ) | [protected, virtual] |
If we want to call the sockets Disconnected member.
Reimplemented in CPClientHandler.
Definition at line 208 of file CPHandler.cpp.
int CPHandler::CallHandleConnection | ( | CPConnection * | pConnection | ) | [virtual] |
Call the CPConnection->HandleConnection This is here so derived classes can choose NOT to call it in case the handler is chained (like the CPClientHandler)
Reimplemented in CPClientHandler.
Definition at line 198 of file CPHandler.cpp.
void CPHandler::DisconnectAll | ( | ) | [protected, virtual] |
Called in the case of an unrecoverable error.
Definition at line 162 of file CPHandler.cpp.
int CPHandler::GetCurrentSize | ( | ) | [virtual] |
Get the current size (will wait for critical seection)
Definition at line 189 of file CPHandler.cpp.
int CPHandler::GetLastSize | ( | ) | [virtual] |
Get the last size (not necesssarily current)
Definition at line 182 of file CPHandler.cpp.
BOOL CPHandler::RemoveConnection | ( | CPConnection * | pConnection | ) | [virtual] |
Remove a connection from our purview.
Definition at line 105 of file CPHandler.cpp.
virtual unsigned CPHandler::WorkerFunction | ( | void * | pParam | ) | [protected, pure virtual] |
Function that does the work.
Implements CXPlatThread.
Implemented in CPClientHandler, and CPConnectionHandler.
BOOL CPHandler::bThreadRunning [protected] |
Faster than querying the thread.
Definition at line 75 of file CPHandler.h.
CXPlatCriticalSection CPHandler::cCritMap [protected] |
To protect cLiveConnections.
Definition at line 63 of file CPHandler.h.
CXPlatCriticalSection CPHandler::cCritQueuedMap [protected] |
To protect cQueuedConnections.
Definition at line 67 of file CPHandler.h.
CONNECTION_MAP CPHandler::cLiveConnections [protected] |
Active connections.
Definition at line 65 of file CPHandler.h.
CONNECTION_MAP CPHandler::cQueuedConnections [protected] |
Will add to cLiveConnections at beginning of each I/O cycle.
Definition at line 69 of file CPHandler.h.
int CPHandler::iLiveSize [protected] |
# in cLiveConnections
Definition at line 71 of file CPHandler.h.
int CPHandler::iSize [protected] |
# in cLiveConnections + cQueuedConnections
Definition at line 73 of file CPHandler.h.