Skip to content

Commit

Permalink
Disable threading on HttpLoader for js
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugh Sanderson committed Jun 9, 2024
1 parent 44bf36b commit 37e802e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/nme/net/HttpLoader.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ 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;
#else
import cpp.vm.Mutex;
import cpp.vm.Thread;
#end
#end

private class OutputWatcher extends haxe.io.BytesOutput
{
Expand All @@ -40,9 +42,11 @@ private class OutputWatcher extends haxe.io.BytesOutput

class HttpLoader
{
#if !js
static var jobs:Array<Void->Void>;
static var mutex:Mutex;
static var workers = 0;
#end


var urlLoader:URLLoader;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -156,6 +163,7 @@ class HttpLoader
//trace(" -> error");
}
}
#end

public function onBytesLoaded(count:Int)
{
Expand Down Expand Up @@ -183,7 +191,7 @@ class HttpLoader
code = inStatus;
}


#if !js
public static function runAsync(job:Void->Void)
{
if (jobs==null)
Expand Down Expand Up @@ -219,6 +227,7 @@ class HttpLoader
job();
}
}
#end


public static function pollAll()
Expand Down
6 changes: 3 additions & 3 deletions tools/make_classes/Export.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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)");
}


Expand All @@ -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;
Expand Down

0 comments on commit 37e802e

Please sign in to comment.