HighResolutionTimer question


#1

I use a class derived HighResolutionTimer.
startTimer works well
But when I call stopTimer in destructor, the app goes into infinite while-loop here

[code]
void stop()
{
if (thread != 0)
{
shouldStop = true;

        while (thread != 0 && thread != pthread_self())
            Thread::yield();
    }
}[/code]

What am I doing wrong?
I’ve downloaded juce from git. I use Mac OS X 10.8


#2

No idea, but your debugger should be able to show you what the timer thread is busy waiting for.


#3

Checked it for windows. It loops here forever

while (! blockingMessage->lockedEvent.wait (20)) { if ((threadToCheck != nullptr && threadToCheck->threadShouldExit()) || (job != nullptr && job->shouldExit())) { blockingMessage->releaseEvent.signal(); blockingMessage = nullptr; mm->lockingLock.exit(); return false; } }
But if to remove TIME_KILL_SYNCHRONOUS from

timerID = timeSetEvent (actualPeriod, tc.wPeriodMin, callbackFunction, (DWORD_PTR) this, TIME_PERIODIC | TIME_CALLBACK_FUNCTION | TIME_KILL_SYNCHRONOUS);
then application exits well


#4

Sure, it’s waiting for a message manager lock, but without a stack trace, that’s useless. You should look at what code you’ve got that’s calling the message manager lock.

BTW, don’t remove TIME_KILL_SYNCHRONOUS, that could be very dangerous!