Remove references to BackgroundWorker.

This commit is contained in:
Joseph Cloutier
2022-03-28 15:01:17 -04:00
parent f31adb845f
commit d4588434b9
4 changed files with 13 additions and 19 deletions

View File

@@ -112,7 +112,6 @@ import lime.net.HTTPRequest;
import lime.net.HTTPRequestHeader; import lime.net.HTTPRequestHeader;
import lime.net.HTTPRequestMethod; import lime.net.HTTPRequestMethod;
import lime.net.URIParser; import lime.net.URIParser;
import lime.system.BackgroundWorker;
import lime.system.CFFI; import lime.system.CFFI;
import lime.system.CFFIPointer; import lime.system.CFFIPointer;
import lime.system.Clipboard; import lime.system.Clipboard;

View File

@@ -2,7 +2,6 @@ package lime.system;
import lime.app.Application; import lime.app.Application;
import lime.app.Event; import lime.app.Event;
import lime.system.BackgroundWorker;
import lime.system.WorkOutput; import lime.system.WorkOutput;
import lime.utils.Log; import lime.utils.Log;
#if target.threaded #if target.threaded
@@ -45,7 +44,6 @@ import lime._internal.backend.html5.HTML5Thread as Thread;
@:fileXml('tags="haxe,release"') @:fileXml('tags="haxe,release"')
@:noDebug @:noDebug
#end #end
@:allow(lime.system.BackgroundWorker)
class ThreadPool extends WorkOutput class ThreadPool extends WorkOutput
{ {
#if lime_threads #if lime_threads

View File

@@ -37,7 +37,6 @@ using haxe.macro.Context;
thread. On many targets it's also possible to access static or instance 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. variables, but this isn't thread safe and won't work in HTML5.
**/ **/
@:allow(lime.system.BackgroundWorker)
@:allow(lime.system.ThreadPool) @:allow(lime.system.ThreadPool)
class WorkOutput class WorkOutput
{ {
@@ -243,15 +242,13 @@ class WorkOutput
In single-threaded mode, the work function shouldn't complete the job all at 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 once, as the main thread would lock up. Instead, it should perform a
fraction of the job each time it's called. `BackgroundWorker` and fraction of the job each time it's called. `ThreadPool` provides the
`ThreadPool` each provide the function with a persistent `State` argument, function with a persistent `State` argument that can track progress.
which can be used to track progress. In other contexts, you may be able to Alternatively, you may be able to bind your own `State` argument.
`bind` your own `State` argument.
If using multi-threaded mode in HTML5, instance methods and `bind()` are Caution: if using multi-threaded mode in HTML5, this must be a static
both forbidden. Inline functions may work as long as they don't try to function and binding arguments is forbidden. Compile with
access `this`, but static functions are preferred. (All of these are fine in `-Dlime-warn-portability` to highlight functions that won't work.
single-threaded mode.)
The exact length of `doWork` can vary, but single-threaded mode will run 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. more smoothly if it's short enough to run several times per frame.

View File

@@ -5,7 +5,7 @@ import haxe.io.Path;
import lime._internal.backend.native.NativeCFFI; import lime._internal.backend.native.NativeCFFI;
import lime.app.Event; import lime.app.Event;
import lime.graphics.Image; import lime.graphics.Image;
import lime.system.BackgroundWorker; import lime.system.ThreadPool;
import lime.utils.ArrayBuffer; import lime.utils.ArrayBuffer;
import lime.utils.Resource; import lime.utils.Resource;
#if hl #if hl
@@ -101,7 +101,7 @@ class FileDialog
if (type == null) type = FileDialogType.OPEN; if (type == null) type = FileDialogType.OPEN;
#if desktop #if desktop
var worker = new BackgroundWorker(); var worker = new ThreadPool();
worker.onComplete.add(function(result) worker.onComplete.add(function(result)
{ {
@@ -139,7 +139,7 @@ class FileDialog
} }
}); });
worker.run(function(_) worker.run(function(_, __)
{ {
switch (type) switch (type)
{ {
@@ -233,7 +233,7 @@ class FileDialog
public function open(filter:String = null, defaultPath:String = null, title:String = null):Bool public function open(filter:String = null, defaultPath:String = null, title:String = null):Bool
{ {
#if desktop #if desktop
var worker = new BackgroundWorker(); var worker = new ThreadPool();
worker.onComplete.add(function(path:String) worker.onComplete.add(function(path:String)
{ {
@@ -251,7 +251,7 @@ class FileDialog
onCancel.dispatch(); onCancel.dispatch();
}); });
worker.run(function(_) worker.run(function(_, __)
{ {
#if linux #if linux
if (title == null) title = "Open File"; if (title == null) title = "Open File";
@@ -299,7 +299,7 @@ class FileDialog
} }
#if desktop #if desktop
var worker = new BackgroundWorker(); var worker = new ThreadPool();
worker.onComplete.add(function(path:String) worker.onComplete.add(function(path:String)
{ {
@@ -317,7 +317,7 @@ class FileDialog
onCancel.dispatch(); onCancel.dispatch();
}); });
worker.run(function(_) worker.run(function(_, __)
{ {
#if linux #if linux
if (title == null) title = "Save File"; if (title == null) title = "Save File";