From 05322f0dfa56cb1a536347a691442968f8fb895f Mon Sep 17 00:00:00 2001 From: Joseph Cloutier Date: Fri, 25 Mar 2022 17:24:43 -0400 Subject: [PATCH] Fix `duration` in multi-threaded mode. --- src/lime/system/ThreadPool.hx | 6 +++--- src/lime/system/WorkOutput.hx | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lime/system/ThreadPool.hx b/src/lime/system/ThreadPool.hx index 326be7af4..f116d7cd9 100644 --- a/src/lime/system/ThreadPool.hx +++ b/src/lime/system/ThreadPool.hx @@ -338,7 +338,7 @@ class ThreadPool extends WorkOutput } while (!Std.isOfType(job, ThreadEvent)); - output.resetJobProgress(); + output.resetJobProgress(timestamp()); } if (job.event == EXIT) @@ -377,7 +377,7 @@ class ThreadPool extends WorkOutput else if(Std.isOfType(interruption, ThreadEvent)) { job = interruption; - output.resetJobProgress(); + output.resetJobProgress(timestamp()); } else { @@ -390,7 +390,7 @@ class ThreadPool extends WorkOutput } #end - private inline function timestamp():Float + private static inline function timestamp():Float { #if sys return Sys.cpuTime(); diff --git a/src/lime/system/WorkOutput.hx b/src/lime/system/WorkOutput.hx index bae54c11f..4e2297659 100644 --- a/src/lime/system/WorkOutput.hx +++ b/src/lime/system/WorkOutput.hx @@ -166,9 +166,14 @@ class WorkOutput } } - private inline function resetJobProgress():Void + /** + @param now `WorkOutput` won't compile if it includes any references to + `haxe.Timer`, so the child class must supply the current time instead. + **/ + private inline function resetJobProgress(now:Float):Void { __jobComplete.value = false; + __jobStartTime.value = now; workIterations.value = 0; }