----------------------------------------------------------------------------- Start a function running on this thread -----------------------------------------------------------------------------
| 68 | // Start a function running on this thread |
| 69 | //----------------------------------------------------------------------------- |
| 70 | bool ThreadImpl::Start |
| 71 | ( |
| 72 | Thread::pfnThreadProc_t _pfnThreadProc, |
| 73 | Event* _exitEvent, |
| 74 | void* _pContext |
| 75 | ) |
| 76 | { |
| 77 | pthread_attr_t ta; |
| 78 | |
| 79 | pthread_attr_init( &ta ); |
| 80 | pthread_attr_setstacksize ( &ta, 0 ); |
| 81 | pthread_attr_setdetachstate ( &ta, PTHREAD_CREATE_JOINABLE ); |
| 82 | |
| 83 | // Create a thread to run the specified function |
| 84 | m_pfnThreadProc = _pfnThreadProc; |
| 85 | m_pContext = _pContext; |
| 86 | m_exitEvent = _exitEvent; |
| 87 | m_exitEvent->Reset(); |
| 88 | |
| 89 | pthread_create ( &m_hThread, &ta, ThreadImpl::ThreadProc, this ); |
| 90 | string threadname("OZW-"); |
| 91 | threadname.append(m_name); |
| 92 | #if !defined(__APPLE_CC__) && !defined(__FreeBSD__) |
| 93 | pthread_setname_np( m_hThread, threadname.c_str() ); |
| 94 | #endif |
| 95 | //fprintf(stderr, "thread %s starting %08x\n", m_name.c_str(), m_hThread); |
| 96 | //fflush(stderr); |
| 97 | |
| 98 | pthread_attr_destroy ( &ta ); |
| 99 | return true; |
| 100 | } |
| 101 | |
| 102 | //----------------------------------------------------------------------------- |
| 103 | // <ThreadImpl::Terminate> |