fix synchronization of TimerState (refs #1729)
This was SVN commit r12908.
This commit is contained in:
parent
3787f17e4d
commit
308db6627a
@ -207,15 +207,10 @@ static void UpdateTimerState()
|
||||
|
||||
double whrt_Time()
|
||||
{
|
||||
retry:
|
||||
// latch timer state (counter and time must be from the same update)
|
||||
const double time = ts->time;
|
||||
COMPILER_FENCE;
|
||||
const u64 counter = ts->counter;
|
||||
// ts changed after reading time. note: don't compare counter because
|
||||
// it _might_ have the same value after two updates.
|
||||
if(time != ts->time)
|
||||
goto retry;
|
||||
const volatile TimerState* state = ts;
|
||||
const double time = state->time;
|
||||
const u64 counter = state->counter;
|
||||
|
||||
const u64 deltaTicks = CounterDelta(counter, Counter());
|
||||
return (time + deltaTicks/nominalFrequency);
|
||||
|
Loading…
Reference in New Issue
Block a user