mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
HiResTimer: Fix units used for threading policy
The values in mach_timebase_info_data_t should be specified in terms of 'ticks'. On some machines, ticks may correspond to nanoseconds, but this is not guaranteed.
This commit is contained in:
parent
857f665f74
commit
452b1bf224
1 changed files with 8 additions and 2 deletions
|
|
@ -1334,9 +1334,15 @@ private:
|
|||
const auto thread = pthread_self();
|
||||
|
||||
#if JUCE_MAC || JUCE_IOS
|
||||
mach_timebase_info_data_t timebase;
|
||||
mach_timebase_info (&timebase);
|
||||
|
||||
const auto ticksPerMs = ((double) timebase.denom * 1000000.0) / (double) timebase.numer;
|
||||
const auto periodTicks = (uint32_t) (ticksPerMs * periodMs);
|
||||
|
||||
thread_time_constraint_policy_data_t policy;
|
||||
policy.period = (uint32_t) (periodMs * 1000000);
|
||||
policy.computation = 50000;
|
||||
policy.period = periodTicks;
|
||||
policy.computation = jmin ((uint32_t) 50000, policy.period);
|
||||
policy.constraint = policy.period;
|
||||
policy.preemptible = true;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue