![]() |
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 67 of file Socket.h.
Socket::SocketThread::SocketThread | ( | Socket * | p | ) |
Socket::SocketThread::~SocketThread | ( | ) |
Definition at line 877 of file Socket.cpp.
References Thread::IsRunning(), Thread::SetRelease(), and Thread::SetRunning().
00878 { 00879 if (IsRunning()) 00880 { 00881 SetRelease(true); 00882 SetRunning(false); 00883 #ifdef _WIN32 00884 Sleep(1000); 00885 #else 00886 sleep(1); 00887 #endif 00888 } 00889 }
Socket::SocketThread::SocketThread | ( | const SocketThread & | s | ) | [inline, private] |
void Socket::SocketThread::Run | ( | ) | [virtual] |
Implements Thread.
Definition at line 892 of file Socket.cpp.
References SocketHandler::Add(), SocketHandler::GetCount(), Thread::IsRunning(), m_socket, Socket::OnDetached(), SocketHandler::Select(), Thread::SetDeleteOnExit(), SocketHandler::SetSlave(), and Socket::SetSlaveHandler().
00893 { 00894 SocketHandler h; 00895 h.SetSlave(); 00896 h.Add(m_socket); 00897 m_socket -> SetSlaveHandler(&h); 00898 m_socket -> OnDetached(); 00899 while (h.GetCount() && IsRunning()) 00900 { 00901 h.Select(0, 500000); 00902 } 00903 // m_socket now deleted oops 00904 // yeah oops m_socket delete its socket thread, that means this 00905 // so Socket will no longer delete its socket thread, instead we do this: 00906 SetDeleteOnExit(); 00907 }
Socket* Socket::SocketThread::GetSocket | ( | ) | const [inline, private] |
SocketThread& Socket::SocketThread::operator= | ( | const SocketThread & | ) | [inline, private] |
Socket* Socket::SocketThread::m_socket [private] |