Conductor Multithreading + in-game frame drops fix

This commit is contained in:
Yoshman29
2022-12-30 18:26:39 +01:00
parent 5cded1a197
commit 48bad77396
7 changed files with 115 additions and 33 deletions
+32
View File
@@ -0,0 +1,32 @@
package funkin.system;
#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