Renamed WorkerThread to BackgroundWorker, improve

This commit is contained in:
Joshua Granick
2015-07-06 10:05:58 -07:00
parent 4ac262d061
commit 0882e27537
3 changed files with 186 additions and 164 deletions

View File

@@ -8,7 +8,7 @@ import lime.audio.AudioSource;
import lime.audio.openal.AL;
import lime.audio.AudioBuffer;
import lime.graphics.Image;
import lime.system.WorkerThread;
import lime.system.BackgroundWorker;
import lime.text.Font;
import lime.utils.ByteArray;
import lime.utils.UInt8Array;
@@ -548,14 +548,15 @@ class DefaultAssetLibrary extends AssetLibrary {
#else
var worker = new WorkerThread ();
worker.doWork = function () {
var worker = new BackgroundWorker ();
worker.doWork.add (function (_) {
var bytes = getBytes (id);
worker.sendUpdate (bytes);
worker.sendComplete (getBytes (id));
}
worker.onUpdate.add (function (msg) handler (msg));
});
worker.onComplete.add (function (bytes) handler (bytes));
worker.run ();
#end
@@ -604,14 +605,15 @@ class DefaultAssetLibrary extends AssetLibrary {
#else
var worker = new WorkerThread ();
worker.doWork = function () {
var worker = new BackgroundWorker ();
worker.doWork.add (function (_) {
var image = getImage (id);
worker.sendUpdate (image);
worker.sendComplete (getImage (id));
}
worker.onUpdate.add (function (msg) handler (msg));
});
worker.onComplete.add (function (image) handler (image));
worker.run ();
#end