perf: fine tune continuous task stealing algorithm
[poolifier.git] / src / pools / worker-node.ts
index 9ecfd012f9b5402c4676004f24f7c04ecc4bf020..fbd00096a769d53cd5d3d9415fae64c428cfb3ee 100644 (file)
@@ -178,7 +178,11 @@ implements IWorkerNode<Worker, Data> {
   }
 
   private async startOnEmptyQueue (): Promise<void> {
-    if (this.tasksQueue.size > 0) {
+    if (
+      this.onEmptyQueueCount > 0 &&
+      this.usage.tasks.executing > 0 &&
+      this.tasksQueue.size > 0
+    ) {
       this.onEmptyQueueCount = 0
       return
     }