|
@@ -118,10 +118,16 @@ int Thread::warteAufThread( int zeit ) // wartet zeit lang auf den Thread
|
|
|
return 0;
|
|
|
if( pthread_self() == threadHandle )
|
|
|
return 0;
|
|
|
+ timespec ts;
|
|
|
+ ts.tv_sec = 0;
|
|
|
+ ts.tv_nsec = 1000 * zeit;
|
|
|
if( threadHandleSys )
|
|
|
*threadHandleSys = 0;
|
|
|
- int ret = pthread_join( threadHandle, 0 );
|
|
|
- threadHandle = 0;
|
|
|
+ int ret = pthread_timedjoin_np( threadHandle, 0, &ts );
|
|
|
+ if( !ret )
|
|
|
+ threadHandle = 0;
|
|
|
+ else
|
|
|
+ *threadHandleSys = threadHandle;
|
|
|
return ret;
|
|
|
#endif
|
|
|
}
|
|
@@ -186,6 +192,15 @@ ThreadRegister::ThreadRegister()
|
|
|
// Destruktor
|
|
|
ThreadRegister::~ThreadRegister()
|
|
|
{
|
|
|
+ EnterCriticalSection( &cs );
|
|
|
+ while( threads.hat( 0 ) )
|
|
|
+ {
|
|
|
+ LeaveCriticalSection( &cs );
|
|
|
+ Sleep( 1000 ); // wait until all threads are done
|
|
|
+ EnterCriticalSection( &cs );
|
|
|
+ }
|
|
|
+ cleanUpClosedThreads();
|
|
|
+ LeaveCriticalSection( &cs );
|
|
|
DeleteCriticalSection( &cs );
|
|
|
}
|
|
|
|