1
0
forked from 0ad/0ad

fix synchronization of TimerState (refs #1729)

This was SVN commit r12908.
This commit is contained in:
janwas 2012-12-01 06:33:30 +00:00
parent 3787f17e4d
commit 308db6627a

View File

@ -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);