Преглед изворни кода

修复一个计算线程调度纤程数量的bug

tanghai пре 2 година
родитељ
комит
9bd25580d7
1 измењених фајлова са 5 додато и 3 уклоњено
  1. 5 3
      Unity/Assets/Scripts/Core/World/Module/Fiber/ThreadPoolScheduler.cs

+ 5 - 3
Unity/Assets/Scripts/Core/World/Module/Fiber/ThreadPoolScheduler.cs

@@ -31,11 +31,13 @@ namespace ET
             int count = 0;
             int count = 0;
             while (true)
             while (true)
             {
             {
-                if (count == 0)
+                if (count <= 0)
                 {
                 {
-                    count = this.fiberManager.Count() / this.threads.Count;
                     Thread.Sleep(1);
                     Thread.Sleep(1);
-                    continue;
+                    
+                    int n = this.fiberManager.Count() / this.threads.Count;
+                    // count最小为1
+                    count = n > 1? n : 1;
                 }
                 }
 
 
                 --count;
                 --count;