moved utils (update your scripts!!!!)

This commit is contained in:
Yoshman29
2023-01-11 14:21:04 +01:00
parent cda6268573
commit 6dd2854d2c
17 changed files with 30 additions and 24 deletions
+32
View File
@@ -0,0 +1,32 @@
package funkin.utils;
#if ALLOW_MULTITHREADING
class ThreadUtil {
/**
* Creates a new Thread with an error handler.
* @param func Function to execute
* @param autoRestart Whenever the thread should auto restart itself after crashing.
*/
public static function createSafe(func:Void->Void, autoRestart:Bool = false) {
if (autoRestart) {
return sys.thread.Thread.create(function() {
while(true) {
try {
func();
} catch(e) {
trace(e.details());
}
}
});
} else {
return sys.thread.Thread.create(function() {
try {
func();
} catch(e) {
trace(e.details());
}
});
}
}
}
#end