give tempScripts thread-safe ids. Close #88
This commit is contained in:
@@ -23,7 +23,9 @@ import python.Bytearray;
|
|||||||
import uuid.Uuid;
|
import uuid.Uuid;
|
||||||
import haxe.io.Path;
|
import haxe.io.Path;
|
||||||
import haxe.Json;
|
import haxe.Json;
|
||||||
|
#if target.threaded
|
||||||
|
import sys.thread.Mutex;
|
||||||
|
#end
|
||||||
using StringTools;
|
using StringTools;
|
||||||
using uuid.Uuid;
|
using uuid.Uuid;
|
||||||
|
|
||||||
@@ -746,13 +748,26 @@ class Prelude {
|
|||||||
return assertProcess("haxelib", ["libpath", haxelibName]).trim();
|
return assertProcess("haxelib", ["libpath", haxelibName]).trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if target.threaded
|
||||||
|
static var shellCountMutex = new Mutex();
|
||||||
|
#end
|
||||||
|
|
||||||
|
static var shellCount = 0;
|
||||||
|
|
||||||
public static function shellExecute(script:String, shell:String) {
|
public static function shellExecute(script:String, shell:String) {
|
||||||
#if (sys || hxnodejs)
|
#if (sys || hxnodejs)
|
||||||
if (shell.length == 0) {
|
if (shell.length == 0) {
|
||||||
shell = if (Sys.systemName() == "Windows") "cmd /c" else "bash";
|
shell = if (Sys.systemName() == "Windows") "cmd /c" else "bash";
|
||||||
}
|
}
|
||||||
|
|
||||||
var tempScript = 'tempScript.${shell.split(" ")[0]}';
|
#if target.threaded
|
||||||
|
shellCountMutex.acquire();
|
||||||
|
#end
|
||||||
|
var tempScript = 'tempScript${shellCount++}.${shell.split(" ")[0]}';
|
||||||
|
#if target.threaded
|
||||||
|
shellCountMutex.release();
|
||||||
|
#end
|
||||||
|
|
||||||
File.saveContent(tempScript, script);
|
File.saveContent(tempScript, script);
|
||||||
try {
|
try {
|
||||||
if (Sys.systemName() != "Windows") tempScript = joinPath(Sys.getCwd(), tempScript);
|
if (Sys.systemName() != "Windows") tempScript = joinPath(Sys.getCwd(), tempScript);
|
||||||
|
Reference in New Issue
Block a user