Logo
~Sockets~
~Examples~
~Contact~


SocketThread Class Reference
[Internal utility]

Detached socket run thread. More...

#include <SocketThread.h>

Inheritance diagram for SocketThread:
Collaboration diagram for SocketThread:

List of all members.


Public Member Functions

 SocketThread (Socket *p)
 ~SocketThread ()
void Run ()

Private Member Functions

 SocketThread (const SocketThread &s)
SocketThreadoperator= (const SocketThread &)

Private Attributes

SocketHandler m_h
Socketm_socket

Detailed Description

Detached socket run thread.

Definition at line 48 of file SocketThread.h.


Constructor & Destructor Documentation

SocketThread::SocketThread ( Socket p  ) 

Definition at line 40 of file SocketThread.cpp.

00041 :Thread(false)
00042 ,m_socket(p)
00043 {
00044         // Creator will release
00045 }

SocketThread::~SocketThread (  ) 

Definition at line 48 of file SocketThread.cpp.

References Thread::IsRunning(), m_h, SocketHandler::Release(), Thread::SetRelease(), Thread::SetRunning(), and Utility::Sleep().

00049 {
00050         if (IsRunning())
00051         {
00052                 SetRelease(true);
00053                 SetRunning(false);
00054                 m_h.Release();
00055                 Utility::Sleep(5);
00056         }
00057 }

SocketThread::SocketThread ( const SocketThread s  )  [inline, private]

Definition at line 57 of file SocketThread.h.

00057 : m_socket(s.m_socket) {}


Member Function Documentation

void SocketThread::Run (  )  [virtual]

Implements Thread.

Definition at line 60 of file SocketThread.cpp.

References SocketHandler::Add(), SocketHandler::EnableRelease(), SocketHandler::GetCount(), Thread::IsRunning(), m_h, m_socket, SocketHandler::Select(), Thread::SetDeleteOnExit(), and SocketHandler::SetSlave().

00061 {
00062         m_h.SetSlave();
00063         m_h.Add(m_socket);
00064         m_socket -> SetSlaveHandler(&m_h);
00065         m_socket -> OnDetached();
00066         m_h.EnableRelease();
00067         while (m_h.GetCount() > 1 && IsRunning())
00068         {
00069                 m_h.Select(0, 500000);
00070         }
00071         // m_socket now deleted oops
00072         //  (a socket can only be detached if DeleteByHandler() is true)
00073         // yeah oops m_socket delete its socket thread, that means this
00074         // so Socket will no longer delete its socket thread, instead we do this:
00075         SetDeleteOnExit();
00076 }

SocketThread& SocketThread::operator= ( const SocketThread  )  [inline, private]

Definition at line 58 of file SocketThread.h.

00058 { return *this; }


Member Data Documentation

Definition at line 60 of file SocketThread.h.

Referenced by Run(), and ~SocketThread().

Definition at line 61 of file SocketThread.h.

Referenced by Run().


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2007 by Anders Hedström
Generated for C++ Sockets by  doxygen 1.4.4