From d4588434b9c9477f8c5c0cfd5f6ec8610761b31f Mon Sep 17 00:00:00 2001 From: Joseph Cloutier Date: Mon, 28 Mar 2022 15:01:17 -0400 Subject: [PATCH] Remove references to `BackgroundWorker`. --- docs/ImportAll.hx | 1 - src/lime/system/ThreadPool.hx | 2 -- src/lime/system/WorkOutput.hx | 15 ++++++--------- src/lime/ui/FileDialog.hx | 14 +++++++------- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/docs/ImportAll.hx b/docs/ImportAll.hx index ed451cc3d..be172c7d0 100644 --- a/docs/ImportAll.hx +++ b/docs/ImportAll.hx @@ -112,7 +112,6 @@ import lime.net.HTTPRequest; import lime.net.HTTPRequestHeader; import lime.net.HTTPRequestMethod; import lime.net.URIParser; -import lime.system.BackgroundWorker; import lime.system.CFFI; import lime.system.CFFIPointer; import lime.system.Clipboard; diff --git a/src/lime/system/ThreadPool.hx b/src/lime/system/ThreadPool.hx index 61c5bf4c3..c998707f7 100644 --- a/src/lime/system/ThreadPool.hx +++ b/src/lime/system/ThreadPool.hx @@ -2,7 +2,6 @@ package lime.system; import lime.app.Application; import lime.app.Event; -import lime.system.BackgroundWorker; import lime.system.WorkOutput; import lime.utils.Log; #if target.threaded @@ -45,7 +44,6 @@ import lime._internal.backend.html5.HTML5Thread as Thread; @:fileXml('tags="haxe,release"') @:noDebug #end -@:allow(lime.system.BackgroundWorker) class ThreadPool extends WorkOutput { #if lime_threads diff --git a/src/lime/system/WorkOutput.hx b/src/lime/system/WorkOutput.hx index f6e9100e3..f7b1b5788 100644 --- a/src/lime/system/WorkOutput.hx +++ b/src/lime/system/WorkOutput.hx @@ -37,7 +37,6 @@ using haxe.macro.Context; thread. On many targets it's also possible to access static or instance variables, but this isn't thread safe and won't work in HTML5. **/ -@:allow(lime.system.BackgroundWorker) @:allow(lime.system.ThreadPool) class WorkOutput { @@ -243,15 +242,13 @@ class WorkOutput In single-threaded mode, the work function shouldn't complete the job all at once, as the main thread would lock up. Instead, it should perform a - fraction of the job each time it's called. `BackgroundWorker` and - `ThreadPool` each provide the function with a persistent `State` argument, - which can be used to track progress. In other contexts, you may be able to - `bind` your own `State` argument. + fraction of the job each time it's called. `ThreadPool` provides the + function with a persistent `State` argument that can track progress. + Alternatively, you may be able to bind your own `State` argument. - If using multi-threaded mode in HTML5, instance methods and `bind()` are - both forbidden. Inline functions may work as long as they don't try to - access `this`, but static functions are preferred. (All of these are fine in - single-threaded mode.) + Caution: if using multi-threaded mode in HTML5, this must be a static + function and binding arguments is forbidden. Compile with + `-Dlime-warn-portability` to highlight functions that won't work. The exact length of `doWork` can vary, but single-threaded mode will run more smoothly if it's short enough to run several times per frame. diff --git a/src/lime/ui/FileDialog.hx b/src/lime/ui/FileDialog.hx index 3839a5a18..c9cea22e6 100644 --- a/src/lime/ui/FileDialog.hx +++ b/src/lime/ui/FileDialog.hx @@ -5,7 +5,7 @@ import haxe.io.Path; import lime._internal.backend.native.NativeCFFI; import lime.app.Event; import lime.graphics.Image; -import lime.system.BackgroundWorker; +import lime.system.ThreadPool; import lime.utils.ArrayBuffer; import lime.utils.Resource; #if hl @@ -101,7 +101,7 @@ class FileDialog if (type == null) type = FileDialogType.OPEN; #if desktop - var worker = new BackgroundWorker(); + var worker = new ThreadPool(); worker.onComplete.add(function(result) { @@ -139,7 +139,7 @@ class FileDialog } }); - worker.run(function(_) + worker.run(function(_, __) { switch (type) { @@ -233,7 +233,7 @@ class FileDialog public function open(filter:String = null, defaultPath:String = null, title:String = null):Bool { #if desktop - var worker = new BackgroundWorker(); + var worker = new ThreadPool(); worker.onComplete.add(function(path:String) { @@ -251,7 +251,7 @@ class FileDialog onCancel.dispatch(); }); - worker.run(function(_) + worker.run(function(_, __) { #if linux if (title == null) title = "Open File"; @@ -299,7 +299,7 @@ class FileDialog } #if desktop - var worker = new BackgroundWorker(); + var worker = new ThreadPool(); worker.onComplete.add(function(path:String) { @@ -317,7 +317,7 @@ class FileDialog onCancel.dispatch(); }); - worker.run(function(_) + worker.run(function(_, __) { #if linux if (title == null) title = "Save File";