From 3c6cfc4d882d18c01b65aeeded9bd2151778ef3d Mon Sep 17 00:00:00 2001 From: Redar13 <93761434+Redar13@users.noreply.github.com> Date: Sat, 21 Sep 2024 16:09:21 +0500 Subject: [PATCH 1/3] Optimize traces --- source/funkin/util/logging/AnsiTrace.hx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/source/funkin/util/logging/AnsiTrace.hx b/source/funkin/util/logging/AnsiTrace.hx index 322a66820f..3061455bb4 100644 --- a/source/funkin/util/logging/AnsiTrace.hx +++ b/source/funkin/util/logging/AnsiTrace.hx @@ -1,7 +1,15 @@ package funkin.util.logging; +#if cpp +import cpp.vm.Mutex; +#end + class AnsiTrace { + #if (cpp && !TREMOVE) + static final _mutex:Mutex = new Mutex(); + #end + // mostly a copy of haxe.Log.trace() // but adds nice cute ANSI things public static function trace(v:Dynamic, ?info:haxe.PosInfos) @@ -15,7 +23,13 @@ class AnsiTrace #elseif lua untyped __define_feature__("use._hx_print", _hx_print(str)); #elseif sys - Sys.println(str); + #if cpp + _mutex.acquire(); + Sys.println(str); + _mutex.release(); + #else + Sys.println(str); + #end #else throw new haxe.exceptions.NotImplementedException() #end From ef5df42fcc2fc88c8c881eb3f2bcb3b9bf949448 Mon Sep 17 00:00:00 2001 From: Redar13 <93761434+Redar13@users.noreply.github.com> Date: Sat, 21 Sep 2024 16:10:11 +0500 Subject: [PATCH 2/3] Update AnsiTrace.hx --- source/funkin/util/logging/AnsiTrace.hx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/funkin/util/logging/AnsiTrace.hx b/source/funkin/util/logging/AnsiTrace.hx index 3061455bb4..530e38436f 100644 --- a/source/funkin/util/logging/AnsiTrace.hx +++ b/source/funkin/util/logging/AnsiTrace.hx @@ -6,9 +6,9 @@ import cpp.vm.Mutex; class AnsiTrace { - #if (cpp && !TREMOVE) - static final _mutex:Mutex = new Mutex(); - #end + #if (cpp && !TREMOVE) + static final _mutex:Mutex = new Mutex(); + #end // mostly a copy of haxe.Log.trace() // but adds nice cute ANSI things @@ -23,13 +23,13 @@ class AnsiTrace #elseif lua untyped __define_feature__("use._hx_print", _hx_print(str)); #elseif sys - #if cpp - _mutex.acquire(); - Sys.println(str); - _mutex.release(); - #else - Sys.println(str); - #end + #if cpp + _mutex.acquire(); + Sys.println(str); + _mutex.release(); + #else + Sys.println(str); + #end #else throw new haxe.exceptions.NotImplementedException() #end From bbfa625445b1319bc7cec5fde4aab0bf35db2d8a Mon Sep 17 00:00:00 2001 From: Redar13 <93761434+Redar13@users.noreply.github.com> Date: Sat, 21 Sep 2024 16:42:40 +0500 Subject: [PATCH 3/3] oh it's exists in sys, great --- source/funkin/util/logging/AnsiTrace.hx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/funkin/util/logging/AnsiTrace.hx b/source/funkin/util/logging/AnsiTrace.hx index 530e38436f..86a8f90d74 100644 --- a/source/funkin/util/logging/AnsiTrace.hx +++ b/source/funkin/util/logging/AnsiTrace.hx @@ -1,12 +1,12 @@ package funkin.util.logging; -#if cpp -import cpp.vm.Mutex; +#if (sys && target.threaded) +import sys.thread.Mutex; #end class AnsiTrace { - #if (cpp && !TREMOVE) + #if (sys && target.threaded && !TREMOVE) static final _mutex:Mutex = new Mutex(); #end @@ -23,7 +23,7 @@ class AnsiTrace #elseif lua untyped __define_feature__("use._hx_print", _hx_print(str)); #elseif sys - #if cpp + #if target.threaded _mutex.acquire(); Sys.println(str); _mutex.release();