![]() |
Socket::SocketThread Class ReferenceDetached socket run thread.
More...
|
Public Member Functions | |
SocketThread (Socket *p) | |
~SocketThread () | |
void | Run () |
Private Member Functions | |
Socket * | GetSocket () const |
SocketThread (const SocketThread &s) | |
SocketThread & | operator= (const SocketThread &) |
Private Attributes | |
Socket * | m_socket |
Definition at line 69 of file Socket.h.
Socket::SocketThread::SocketThread | ( | Socket * | p | ) |
Socket::SocketThread::~SocketThread | ( | ) |
Definition at line 1164 of file Socket.cpp.
References Thread::IsRunning(), Thread::SetRelease(), and Thread::SetRunning().
01165 { 01166 if (IsRunning()) 01167 { 01168 SetRelease(true); 01169 SetRunning(false); 01170 #ifdef _WIN32 01171 Sleep(1000); 01172 #else 01173 sleep(1); 01174 #endif 01175 } 01176 }
Socket::SocketThread::SocketThread | ( | const SocketThread & | s | ) | [inline, private] |
void Socket::SocketThread::Run | ( | ) | [virtual] |
Implements Thread.
Definition at line 1179 of file Socket.cpp.
References SocketHandler::Add(), SocketHandler::GetCount(), Thread::IsRunning(), m_socket, Socket::OnDetached(), SocketHandler::Select(), Thread::SetDeleteOnExit(), ISocketHandler::SetSlave(), and Socket::SetSlaveHandler().
01180 { 01181 SocketHandler h; 01182 h.SetSlave(); 01183 h.Add(m_socket); 01184 m_socket -> SetSlaveHandler(&h); 01185 m_socket -> OnDetached(); 01186 while (h.GetCount() && IsRunning()) 01187 { 01188 h.Select(0, 500000); 01189 } 01190 // m_socket now deleted oops 01191 // yeah oops m_socket delete its socket thread, that means this 01192 // so Socket will no longer delete its socket thread, instead we do this: 01193 SetDeleteOnExit(); 01194 }
Socket* Socket::SocketThread::GetSocket | ( | ) | const [inline, private] |
SocketThread& Socket::SocketThread::operator= | ( | const SocketThread & | ) | [inline, private] |
Socket* Socket::SocketThread::m_socket [private] |