new attempt to fix thread issues

This commit is contained in:
csoler 2016-05-11 22:18:02 -04:00
parent 383e40324d
commit 96012ef81f
2 changed files with 11 additions and 6 deletions

View File

@ -127,7 +127,13 @@ void RsTickingThread::fullstop()
#ifdef DEBUG_THREADS
THREAD_DEBUG << " waiting stop" << std::endl;
#endif
mHasStoppedSemaphore.wait();
if(pthread_equal(mTid,pthread_self()))
{
std::cerr << "(WW) RsTickingThread::fullstop() called by same thread. This is unexpected." << std::endl;
return ;
}
mHasStoppedSemaphore.wait_no_relock();
#ifdef DEBUG_THREADS
THREAD_DEBUG << " finished!" << std::endl;
#endif

View File

@ -211,7 +211,9 @@ public:
return s->val ;
}
void wait()
// waits but does not re-locks the semaphore
void wait_no_relock()
{
static const uint32_t max_waiting_time_before_warning=1000 *5 ; // 5 secs
uint32_t tries=0;
@ -224,10 +226,7 @@ public:
RS_STACK_MUTEX(s->mtx) ;
if(s->val > 0)
{
--(s->val) ;
return ;
}
return ;
}
}