Unify busy waiting behavior across conditional compilation branches (#2508)
* Unify busy waiting behavior across conditional compilation branches * Inline busy waiting code instead of using static function
This commit is contained in:
parent
ae715ba0d8
commit
8c55b40e9e
1 changed files with 5 additions and 6 deletions
11
src/rcore.c
11
src/rcore.c
|
@ -4826,15 +4826,14 @@ static void InitTimer(void)
|
||||||
// Ref: http://www.geisswerks.com/ryan/FAQS/timing.html --> All about timming on Win32!
|
// Ref: http://www.geisswerks.com/ryan/FAQS/timing.html --> All about timming on Win32!
|
||||||
void WaitTime(double seconds)
|
void WaitTime(double seconds)
|
||||||
{
|
{
|
||||||
#if defined(SUPPORT_BUSY_WAIT_LOOP)
|
#if defined(SUPPORT_BUSY_WAIT_LOOP) || defined(SUPPORT_PARTIALBUSY_WAIT_LOOP)
|
||||||
double previousTime = GetTime();
|
double destinationTime = GetTime() + seconds;
|
||||||
double currentTime = 0.0;
|
#endif
|
||||||
|
|
||||||
// Busy wait loop
|
#if defined(SUPPORT_BUSY_WAIT_LOOP)
|
||||||
while ((currentTime - previousTime) < seconds) currentTime = GetTime();
|
while (GetTime() < destinationTime) { }
|
||||||
#else
|
#else
|
||||||
#if defined(SUPPORT_PARTIALBUSY_WAIT_LOOP)
|
#if defined(SUPPORT_PARTIALBUSY_WAIT_LOOP)
|
||||||
double destinationTime = GetTime() + seconds;
|
|
||||||
double sleepSeconds = seconds - seconds*0.05; // NOTE: We reserve a percentage of the time for busy waiting
|
double sleepSeconds = seconds - seconds*0.05; // NOTE: We reserve a percentage of the time for busy waiting
|
||||||
#else
|
#else
|
||||||
double sleepSeconds = seconds;
|
double sleepSeconds = seconds;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue