浏览代码

fix #351: support hloop_process_events(loop, 0)

ithewei 2 年之前
父节点
当前提交
a59228663f
共有 2 个文件被更改,包括 2 次插入2 次删除
  1. 1 1
      event/hloop.c
  2. 1 1
      event/hloop.h

+ 1 - 1
event/hloop.c

@@ -155,7 +155,7 @@ int hloop_process_events(hloop_t* loop, int timeout_ms) {
             int64_t min_timeout = TIMER_ENTRY(loop->realtimers.root)->next_timeout - hloop_now_us(loop);
             blocktime_us = MIN(blocktime_us, min_timeout);
         }
-        if (blocktime_us <= 0) goto process_timers;
+        if (blocktime_us < 0) goto process_timers;
         blocktime_ms = blocktime_us / 1000 + 1;
         blocktime_ms = MIN(blocktime_ms, timeout_ms);
     }

+ 1 - 1
event/hloop.h

@@ -131,7 +131,7 @@ HV_EXPORT hloop_t* hloop_new(int flags DEFAULT(HLOOP_FLAG_AUTO_FREE));
 // WARN: Forbid to call hloop_free if HLOOP_FLAG_AUTO_FREE set.
 HV_EXPORT void hloop_free(hloop_t** pp);
 
-HV_EXPORT int hloop_process_events(hloop_t* loop, int timeout_ms DEFAULT(1));
+HV_EXPORT int hloop_process_events(hloop_t* loop, int timeout_ms DEFAULT(0));
 
 // NOTE: when no active events, loop will quit if HLOOP_FLAG_QUIT_WHEN_NO_ACTIVE_EVENTS set.
 HV_EXPORT int hloop_run(hloop_t* loop);