![]() |
Vault
4.1
|
VSocketThread is an abstract base class, derived from VThread, that has both a VSocket, on which it presumably communicates with a client, and an owner VThread, which is presumably the VListenerThread that it. More...
#include <vsocketthread.h>
Public Member Functions | |
VSocketThread (const VString &threadBaseName, VSocket *socket, VListenerThread *ownerThread) | |
Constructs the socket thread with the specified socket and owner thread. | |
virtual | ~VSocketThread () |
Virtual destructor. | |
VSocket * | getSocket () const |
Returns this thread's socket object. | |
VListenerThread * | getOwnerThread () const |
Returns this thread's owner listener thread. | |
void | closeAndStop () |
Closes the socket and stops the thread (causing it to end) in one shot. | |
Protected Attributes | |
VSocket * | mSocket |
The socket this thread is managing. | |
VListenerThread * | mOwnerThread |
The thread that created this one. | |
Friends | |
class | VListenerThread |
VSocketThread is an abstract base class, derived from VThread, that has both a VSocket, on which it presumably communicates with a client, and an owner VThread, which is presumably the VListenerThread that it.
If a subclass so chooses, it can arrange for the owner thread class to keep track of the threads it owns, and for the owned threads to notify the owner when they terminate. VListenerThread already implements the owner side of this arrangement.
Definition at line 34 of file vsocketthread.h.
VSocketThread::VSocketThread | ( | const VString & | threadBaseName, |
VSocket * | socket, | ||
VListenerThread * | ownerThread | ||
) |
Constructs the socket thread with the specified socket and owner thread.
I decided to make the ownerThread a VListenerThread rather than a generic VThread, because I don't think it's appropriate to make VThread have knowledge of sockets. It's less ugly to say that VSocketThread knows about listeners, because you generally use socket threads with listeners. Either way there is some cross-domain knowledge between threads and sockets; this seems the cleaner of the two options.
threadBaseName | a distinguishing base name for the thread, useful for debugging purposes; the thread name will be composed of this and the socket's IP address and port |
socket | the socket this thread is managing |
ownerThread | the thread that created this one |
Definition at line 14 of file vsocketthread.cpp.
VSocket * VSocketThread::getSocket | ( | ) | const |
Returns this thread's socket object.
Definition at line 35 of file vsocketthread.cpp.
References mSocket.
VListenerThread * VSocketThread::getOwnerThread | ( | ) | const |
Returns this thread's owner listener thread.
Definition at line 39 of file vsocketthread.cpp.
References mOwnerThread.