This commit is contained in:
Volker Fischer 2013-03-04 16:11:37 +00:00
parent 9abc744a60
commit 3c790d28df
2 changed files with 16 additions and 9 deletions

View file

@ -118,8 +118,7 @@ CHighPrecisionTimer::CHighPrecisionTimer() :
(uint64_t) timeBaseInfo.numer; (uint64_t) timeBaseInfo.numer;
#else #else
// set delay // set delay
Delay.tv_sec = 0; Delay = iNsDelay;
Delay.tv_nsec = iNsDelay;
#endif #endif
} }
@ -133,12 +132,16 @@ void CHighPrecisionTimer::Start()
// set initial end time // set initial end time
#if defined ( __APPLE__ ) || defined ( __MACOSX ) #if defined ( __APPLE__ ) || defined ( __MACOSX )
NextEnd = mach_absolute_time(); NextEnd = mach_absolute_time() + Delay;
NextEnd += Delay;
#else #else
clock_gettime ( CLOCK_MONOTONIC, &NextEnd ); clock_gettime ( CLOCK_MONOTONIC, &NextEnd );
NextEnd.tv_sec += Delay.tv_sec;
NextEnd.tv_nsec += Delay.tv_nsec; NextEnd.tv_nsec += Delay;
if ( NextEnd.tv_nsec >= 1000000000L )
{
NextEnd.tv_sec++;
NextEnd.tv_nsec -= 1000000000L;
}
#endif #endif
// start thread // start thread
@ -176,8 +179,12 @@ void CHighPrecisionTimer::run()
&NextEnd, &NextEnd,
NULL ); NULL );
NextEnd.tv_sec += Delay.tv_sec; NextEnd.tv_nsec += Delay;
NextEnd.tv_nsec += Delay.tv_nsec; if ( NextEnd.tv_nsec >= 1000000000L )
{
NextEnd.tv_sec++;
NextEnd.tv_nsec -= 1000000000L;
}
#endif #endif
} }
} }

View file

@ -100,7 +100,7 @@ protected:
uint64_t Delay; uint64_t Delay;
uint64_t NextEnd; uint64_t NextEnd;
#else #else
timespec Delay; long Delay;
timespec NextEnd; timespec NextEnd;
#endif #endif