浏览代码

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
pull/2513/head
flashback-fx 3 年前
committed by GitHub
父节点
当前提交
8c55b40e9e
找不到此签名对应的密钥 GPG 密钥 ID: 4AEE18F83AFDEB23
共有 1 个文件被更改,包括 5 次插入6 次删除
  1. +5
    -6
      src/rcore.c

+ 5
- 6
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)
double previousTime = GetTime();
double currentTime = 0.0;
#if defined(SUPPORT_BUSY_WAIT_LOOP) || defined(SUPPORT_PARTIALBUSY_WAIT_LOOP)
double destinationTime = GetTime() + seconds;
#endif
// Busy wait loop
while (p">(currentTime - previousTime) < seconds) currentTime = GetTime();
#if defined(SUPPORT_BUSY_WAIT_LOOP)
while (n">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;

正在加载...
取消
保存