Explorar o código

added support for multithread loader

Nicolas Cannasse hai 1 día
pai
achega
e54fcd4582
Modificáronse 2 ficheiros con 14 adicións e 0 borrados
  1. 7 0
      hxd/fs/FileEntry.hx
  2. 7 0
      hxd/res/Loader.hx

+ 7 - 0
hxd/fs/FileEntry.hx

@@ -14,7 +14,14 @@ class FileEntry {
 	public function readBytes( out : haxe.io.Bytes, outPos : Int, pos : Int, len : Int ) : Int { throw "readBytes() not implemented"; }
 
 
+	#if heaps_mt_loader
+	static var TMP_BYTES(get,set) : haxe.io.Bytes;
+	static var bytesValue = new sys.thread.Tls<haxe.io.Bytes>();
+	static function get_TMP_BYTES() return bytesValue.value;
+	static function set_TMP_BYTES(v) return bytesValue.value = v;
+	#else
 	static var TMP_BYTES : haxe.io.Bytes = null;
+	#end
 	/**
 		Similar to readBytes except :
 		a) a temporary buffer is reused, meaning a single fetchBytes must occur at a single time

+ 7 - 0
hxd/res/Loader.hx

@@ -6,7 +6,14 @@ class Loader {
 		Set when initializing hxd.Res, or manually.
 		Allows code to resolve resources without compiling hxd.Res
 	*/
+	#if heaps_mt_loader
+	public static var currentInstance(get,set) : Loader;
+	static var loaderValue = new sys.thread.Tls<Loader>();
+	static function get_currentInstance() return loaderValue.value;
+	static function set_currentInstance(v) return loaderValue.value = v;
+	#else
 	public static var currentInstance : Loader;
+	#end
 
 	public var fs(default,null) : hxd.fs.FileSystem;
 	var cache : Map<String,Dynamic>;