1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Modified the posix HighResolutionTimer to cope with being started/stopped from its own callback.

This commit is contained in:
jules 2014-08-01 09:11:30 +01:00
parent ed0bed9af7
commit 6773fc2f4f

View file

@ -1146,15 +1146,23 @@ struct HighResolutionTimer::Pimpl
{
if (periodMs != newPeriod)
{
stop();
periodMs = newPeriod;
if (thread != pthread_self())
{
stop();
shouldStop = false;
periodMs = newPeriod;
shouldStop = false;
if (pthread_create (&thread, nullptr, timerThread, this) == 0)
setThreadToRealtime (thread, (uint64) newPeriod);
if (pthread_create (&thread, nullptr, timerThread, this) == 0)
setThreadToRealtime (thread, (uint64) newPeriod);
else
jassertfalse;
}
else
jassertfalse;
{
periodMs = newPeriod;
shouldStop = false;
}
}
}
@ -1191,12 +1199,19 @@ private:
void timerThread()
{
Clock clock (periodMs);
int lastPeriod = periodMs;
Clock clock (lastPeriod);
while (! shouldStop)
{
clock.wait();
owner.hiResTimerCallback();
if (lastPeriod != periodMs)
{
lastPeriod = periodMs;
clock = Clock (lastPeriod);
}
}
periodMs = 0;