diff --git a/src/lime/app/Future.hx b/src/lime/app/Future.hx index 991b0d119..ade129e06 100644 --- a/src/lime/app/Future.hx +++ b/src/lime/app/Future.hx @@ -419,26 +419,26 @@ import lime.utils.Log; private static function singleThreadPool_onComplete(result:Dynamic):Void { - singleThreadPool.eventData.state.promise.complete(result); + singleThreadPool.jobData.state.promise.complete(result); } private static function singleThreadPool_onError(error:Dynamic):Void { - singleThreadPool.eventData.state.promise.error(error); + singleThreadPool.jobData.state.promise.error(error); } #if lime_threads private static function multiThreadPool_onComplete(result:Dynamic):Void { - var promise:Promise = promises[multiThreadPool.eventData.state]; - promises.remove(multiThreadPool.eventData.state); + var promise:Promise = promises[multiThreadPool.jobData.state]; + promises.remove(multiThreadPool.jobData.state); promise.complete(result); } private static function multiThreadPool_onError(error:Dynamic):Void { - var promise:Promise = promises[multiThreadPool.eventData.state]; - promises.remove(multiThreadPool.eventData.state); + var promise:Promise = promises[multiThreadPool.jobData.state]; + promises.remove(multiThreadPool.jobData.state); promise.error(error); } #end diff --git a/src/lime/system/BackgroundWorker.hx b/src/lime/system/BackgroundWorker.hx index dab6d78ad..652e8d160 100644 --- a/src/lime/system/BackgroundWorker.hx +++ b/src/lime/system/BackgroundWorker.hx @@ -33,17 +33,22 @@ import lime.system.ThreadPool; abstract BackgroundWorker(ThreadPool) { private static var __doWorkWrapper:WorkFunctionWorkOutput->Void>; - private static var __eventData:EventData = new EventData(); + private static var __jobData:JobData = new JobData(); @:deprecated("Instead pass the callback to BackgroundWorker.run().") @:noCompletion @:dox(hide) public var doWork(get, never):{ add: (Dynamic->Void) -> Void }; - public var eventData(get, never):EventData; + /** + Additional information about the job that triggered the current + `onComplete`, `onError`, or `onProgress` event. Will only be available + when one of those events is ongoing. + **/ + public var jobData(get, never):JobData; /** __Call this only from the main thread.__ - @param mode Defaults to `MULTI_THREAEDED` on most targets, but + @param mode Defaults to `MULTI_THREADED` on most targets, but `SINGLE_THREADED` in HTML5. In HTML5, `MULTI_THREADED` mode uses web workers, which impose additional restrictions. @param workLoad (Single-threaded mode only) A rough estimate of how much @@ -65,10 +70,8 @@ abstract BackgroundWorker(ThreadPool) Cancels one active or queued job. **/ // A copy of `ThreadPool.cancelJob()` with replacements: - // - Find "__activeJobs", replace with "this.__activeJobs". - // - Find "__idleThreads", replace with "this.__idleThreads". - // - Find "__jobQueue", replace with "this.__jobQueue". - // - Find ".state", replace with ".state.state". + // - Find the string "__", replace with "this.__". + // - Find the string ".state", replace with ".state.state". // Other than that, keep the functions exactly in sync. public function cancelJob(state:State):Bool { @@ -131,15 +134,15 @@ abstract BackgroundWorker(ThreadPool) // Getters & Setters - private function get_eventData():EventData + private function get_jobData():JobData { - if (this.eventData.state != null) + if (this.jobData.state != null) { - __eventData.state = this.eventData.state.state; + __jobData.state = this.jobData.state.state; } - __eventData.duration = this.eventData.duration; + __jobData.duration = this.jobData.duration; - return __eventData; + return __jobData; } private function get_doWork() diff --git a/src/lime/system/ThreadPool.hx b/src/lime/system/ThreadPool.hx index f116d7cd9..0e3e708f6 100644 --- a/src/lime/system/ThreadPool.hx +++ b/src/lime/system/ThreadPool.hx @@ -133,10 +133,10 @@ class ThreadPool extends WorkOutput /** Additional information about the job that triggered the current - `onComplete`, `onError`, or `onProgress` event. Think of this as an - additional argument to the event listener. + `onComplete`, `onError`, or `onProgress` event. Will only be available + when one of those events is ongoing. **/ - public var eventData(default, null):EventData = new EventData(); + public var jobData(default, null):JobData = new JobData(); @:deprecated("Instead pass the callback to ThreadPool's constructor.") @:noCompletion @:dox(hide) public var doWork(get, never):{ add: (Dynamic->Void) -> Void }; @@ -144,8 +144,8 @@ class ThreadPool extends WorkOutput #if lime_threads /** - A list of idle threads. Not to be confused with `idleThreads`, which is - `__idleThreads.length`. + A list of idle threads. Not to be confused with `idleThreads`, a public + variable equal to `__idleThreads.length`. **/ private var __idleThreads:List = new List(); #end @@ -217,7 +217,7 @@ class ThreadPool extends WorkOutput if (error != null) { - eventData.state = job.workEvent.state; + jobData.state = job.workEvent.state; onError.dispatch(error); } } @@ -236,14 +236,14 @@ class ThreadPool extends WorkOutput { for (job in __jobQueue) { - eventData.state = job.state; + jobData.state = job.state; onError.dispatch(error); } } __jobQueue.clear(); __jobComplete.value = false; - eventData.clear(); + jobData.clear(); completed = false; canceled = true; } @@ -487,8 +487,8 @@ class ThreadPool extends WorkOutput continue; } - eventData.state = threadEvent.associatedJob.workEvent.state; - eventData.duration = mode == MULTI_THREADED ? timestamp() - threadEvent.jobStartTime : threadEvent.associatedJob.workTime; + jobData.state = threadEvent.associatedJob.workEvent.state; + jobData.duration = mode == MULTI_THREADED ? timestamp() - threadEvent.jobStartTime : threadEvent.associatedJob.workTime; switch (threadEvent.event) { @@ -531,7 +531,7 @@ class ThreadPool extends WorkOutput default: } - eventData.clear(); + jobData.clear(); } if (completed) @@ -616,7 +616,7 @@ class ThreadPool extends WorkOutput **/ @:allow(lime.system.ThreadPool) @:allow(lime.system.BackgroundWorker) -class EventData +class JobData { /** The original `State` object passed to the job.