浏览代码

use this_thread::yield replace msleep(1)

ithewei 7 年之前
父节点
当前提交
1740893bce
共有 1 个文件被更改,包括 3 次插入5 次删除
  1. 3 5
      hthread.h

+ 3 - 5
hthread.h

@@ -3,7 +3,6 @@
 
 #include "hdef.h"
 #include "hplatform.h"
-#include "htime.h" // for msleep
 #include <thread>
 #include <atomic>
 
@@ -76,14 +75,13 @@ public:
 
     virtual void run() {
         while (status != STOP) {
-            if (status == PAUSE) {
-                msleep(1);
-                continue;
+            while (status == PAUSE) {
+                std::this_thread::yield();
             }
 
             doTask();
 
-            msleep(1);
+            std::this_thread::yield();
         }
     }