From 37e802ed323a22c16c81ea5f8d28051d83648a99 Mon Sep 17 00:00:00 2001 From: Hugh Sanderson Date: Sun, 9 Jun 2024 20:49:30 +0800 Subject: [PATCH] Disable threading on HttpLoader for js --- src/nme/net/HttpLoader.hx | 11 ++++++++++- tools/make_classes/Export.hx | 6 +++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/nme/net/HttpLoader.hx b/src/nme/net/HttpLoader.hx index 8523e192c..81fdaefd5 100644 --- a/src/nme/net/HttpLoader.hx +++ b/src/nme/net/HttpLoader.hx @@ -7,6 +7,7 @@ import nme.events.ProgressEvent; import nme.events.HTTPStatusEvent; import nme.utils.ByteArray; import haxe.Http; +#if !js #if haxe4 import sys.thread.Mutex; import sys.thread.Thread; @@ -14,6 +15,7 @@ import sys.thread.Thread; import cpp.vm.Mutex; import cpp.vm.Thread; #end +#end private class OutputWatcher extends haxe.io.BytesOutput { @@ -40,9 +42,11 @@ private class OutputWatcher extends haxe.io.BytesOutput class HttpLoader { + #if !js static var jobs:ArrayVoid>; static var mutex:Mutex; static var workers = 0; + #end var urlLoader:URLLoader; @@ -82,9 +86,12 @@ class HttpLoader if (isPost) http.setPostBytes(urlRequest.nmeBytes); + #if !js runAsync(run); + #end } + #if !js public function run() { var output = new OutputWatcher(this); @@ -156,6 +163,7 @@ class HttpLoader //trace(" -> error"); } } + #end public function onBytesLoaded(count:Int) { @@ -183,7 +191,7 @@ class HttpLoader code = inStatus; } - + #if !js public static function runAsync(job:Void->Void) { if (jobs==null) @@ -219,6 +227,7 @@ class HttpLoader job(); } } + #end public static function pollAll() diff --git a/tools/make_classes/Export.hx b/tools/make_classes/Export.hx index 75a231942..363f2d279 100644 --- a/tools/make_classes/Export.hx +++ b/tools/make_classes/Export.hx @@ -4,9 +4,9 @@ import ImportAll; class Export { @:native("typeof") - @:extern inline static function typeOf(d:Dynamic):String + extern inline static function typeOf(d:Dynamic):String { - return untyped __js__("typeof(d)"); + return untyped js.Syntax.code("typeof(d)"); } @@ -15,7 +15,7 @@ class Export untyped __define_feature__("use.$iterator", {}); untyped __define_feature__("use.$bind", {}); - var global:Dynamic = untyped __js__("$global"); + var global:Dynamic = untyped js.Syntax.code("$global"); global.nmeClassesLoaded = true; // String map hack global.__map_reserved = untyped __map_reserved;