diff --git a/stepmania/src/arch/Threads/Threads_Pthreads.cpp b/stepmania/src/arch/Threads/Threads_Pthreads.cpp index 1132ab2604..5f08f5bfa5 100644 --- a/stepmania/src/arch/Threads/Threads_Pthreads.cpp +++ b/stepmania/src/arch/Threads/Threads_Pthreads.cpp @@ -96,7 +96,7 @@ static void *StartThread( void *pData ) *pThis->m_piThreadID = pThis->GetThreadId(); /* Tell MakeThread that we've set m_piThreadID, so it's safe to return. */ - sem_post( &pThis->m_StartFinishedSem ); + pThis->m_StartFinishedSem->Post(); return (void *) pThis->m_pFunc( pThis->m_pData ); } @@ -107,17 +107,16 @@ ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, uint64_t *piThre thread->m_pFunc = pFunc; thread->m_pData = pData; thread->m_piThreadID = piThreadID; - sem_init( &thread->m_StartFinishedSem, 0, 0 ); + + thread->m_StartFinishedSem = new SemaImpl_Pthreads( 0 ); int ret = pthread_create( &thread->thread, NULL, StartThread, thread ); if( ret ) FAIL_M( ssprintf( "MakeThread: pthread_create: %s", strerror(errno)) ); /* Don't return until StartThread sets m_piThreadID. */ - ret = sem_wait( &thread->m_StartFinishedSem ); - if( ret ) - FAIL_M( ssprintf( "MakeThread: sem_wait: %s", strerror(errno)) ); - sem_destroy( &thread->m_StartFinishedSem ); + thread->m_StartFinishedSem->Wait(); + delete thread->m_StartFinishedSem; return thread; } diff --git a/stepmania/src/arch/Threads/Threads_Pthreads.h b/stepmania/src/arch/Threads/Threads_Pthreads.h index e5387e9272..299f9aaf61 100644 --- a/stepmania/src/arch/Threads/Threads_Pthreads.h +++ b/stepmania/src/arch/Threads/Threads_Pthreads.h @@ -30,7 +30,7 @@ public: int (*m_pFunc)( void *pData ); void *m_pData; uint64_t *m_piThreadID; - sem_t m_StartFinishedSem; + SemaImpl *m_StartFinishedSem; void Halt( bool Kill ); void Resume();