Vault  4.1
Public Member Functions | Protected Attributes | Friends
VSocketThread Class Reference

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>

Inheritance diagram for VSocketThread:
VThread VMessageInputThread VMessageOutputThread VBentoMessageInputThread

List of all members.

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.
VSocketgetSocket () const
 Returns this thread's socket object.
VListenerThreadgetOwnerThread () 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

VSocketmSocket
 The socket this thread is managing.
VListenerThreadmOwnerThread
 The thread that created this one.

Friends

class VListenerThread

Detailed Description

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.

See also:
VListenerThread

Definition at line 34 of file vsocketthread.h.


Constructor & Destructor Documentation

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.

Parameters:
threadBaseNamea 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
socketthe socket this thread is managing
ownerThreadthe thread that created this one

Definition at line 14 of file vsocketthread.cpp.


Member Function Documentation

VSocket * VSocketThread::getSocket ( ) const

Returns this thread's socket object.

Returns:
a pointer to the VSocket

Definition at line 35 of file vsocketthread.cpp.

References mSocket.

VListenerThread * VSocketThread::getOwnerThread ( ) const

Returns this thread's owner listener thread.

Returns:
a pointer to the VListenerThread

Definition at line 39 of file vsocketthread.cpp.

References mOwnerThread.


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

Copyright ©1997-2014 Trygve Isaacson. All rights reserved. This documentation was generated with Doxygen.