diff --git a/ARMeilleure/Translation/Translator.cs b/ARMeilleure/Translation/Translator.cs index 6531e9f0..4725ca59 100644 --- a/ARMeilleure/Translation/Translator.cs +++ b/ARMeilleure/Translation/Translator.cs @@ -58,9 +58,12 @@ namespace ARMeilleure.Translation { if (Interlocked.Increment(ref _threadCount) == 1) { - Thread backgroundTranslatorThread = new Thread(TranslateQueuedSubs); + Thread backgroundTranslatorThread = new Thread(TranslateQueuedSubs) + { + Name = "CPU.BackgroundTranslatorThread", + Priority = ThreadPriority.Lowest + }; - backgroundTranslatorThread.Priority = ThreadPriority.Lowest; backgroundTranslatorThread.Start(); } diff --git a/Ryujinx.Audio/Renderers/OpenAL/OpenALAudioOut.cs b/Ryujinx.Audio/Renderers/OpenAL/OpenALAudioOut.cs index 69f36a4d..30b325a5 100644 --- a/Ryujinx.Audio/Renderers/OpenAL/OpenALAudioOut.cs +++ b/Ryujinx.Audio/Renderers/OpenAL/OpenALAudioOut.cs @@ -70,7 +70,10 @@ namespace Ryujinx.Audio _context = new AudioContext(); _tracks = new ConcurrentDictionary(); _keepPolling = true; - _audioPollerThread = new Thread(AudioPollerWork); + _audioPollerThread = new Thread(AudioPollerWork) + { + Name = "Audio.PollerThread" + }; _audioPollerThread.Start(); } diff --git a/Ryujinx.Common/Logging/Formatters/DefaultLogFormatter.cs b/Ryujinx.Common/Logging/Formatters/DefaultLogFormatter.cs index c6605e0e..73b0e2b6 100644 --- a/Ryujinx.Common/Logging/Formatters/DefaultLogFormatter.cs +++ b/Ryujinx.Common/Logging/Formatters/DefaultLogFormatter.cs @@ -18,8 +18,13 @@ namespace Ryujinx.Common.Logging sb.AppendFormat(@"{0:hh\:mm\:ss\.fff}", args.Time); sb.Append(" | "); - sb.AppendFormat("{0:d4}", args.ThreadId); - sb.Append(' '); + + if (args.ThreadName != null) + { + sb.Append(args.ThreadName); + sb.Append(' '); + } + sb.Append(args.Message); if (args.Data != null) diff --git a/Ryujinx.Common/Logging/LogEventArgs.cs b/Ryujinx.Common/Logging/LogEventArgs.cs index 2330dedd..af334632 100644 --- a/Ryujinx.Common/Logging/LogEventArgs.cs +++ b/Ryujinx.Common/Logging/LogEventArgs.cs @@ -4,28 +4,28 @@ namespace Ryujinx.Common.Logging { public class LogEventArgs : EventArgs { - public LogLevel Level { get; private set; } - public TimeSpan Time { get; private set; } - public int ThreadId { get; private set; } + public LogLevel Level { get; private set; } + public TimeSpan Time { get; private set; } + public string ThreadName { get; private set; } public string Message { get; private set; } public object Data { get; private set; } - public LogEventArgs(LogLevel level, TimeSpan time, int threadId, string message) + public LogEventArgs(LogLevel level, TimeSpan time, string threadName, string message) { - Level = level; - Time = time; - ThreadId = threadId; - Message = message; + Level = level; + Time = time; + ThreadName = threadName; + Message = message; } - public LogEventArgs(LogLevel level, TimeSpan time, int threadId, string message, object data) + public LogEventArgs(LogLevel level, TimeSpan time, string threadName, string message, object data) { - Level = level; - Time = time; - ThreadId = threadId; - Message = message; - Data = data; + Level = level; + Time = time; + ThreadName = threadName; + Message = message; + Data = data; } } } \ No newline at end of file diff --git a/Ryujinx.Common/Logging/Logger.cs b/Ryujinx.Common/Logging/Logger.cs index 83af97b1..e3d82201 100644 --- a/Ryujinx.Common/Logging/Logger.cs +++ b/Ryujinx.Common/Logging/Logger.cs @@ -155,7 +155,7 @@ namespace Ryujinx.Common.Logging { if (m_EnabledLevels[(int)logLevel] && m_EnabledClasses[(int)logClass]) { - Updated?.Invoke(null, new LogEventArgs(logLevel, m_Time.Elapsed, Thread.CurrentThread.ManagedThreadId, message)); + Updated?.Invoke(null, new LogEventArgs(logLevel, m_Time.Elapsed, Thread.CurrentThread.Name, message)); } } @@ -163,7 +163,7 @@ namespace Ryujinx.Common.Logging { if (m_EnabledLevels[(int)logLevel] && m_EnabledClasses[(int)logClass]) { - Updated?.Invoke(null, new LogEventArgs(logLevel, m_Time.Elapsed, Thread.CurrentThread.ManagedThreadId, message, data)); + Updated?.Invoke(null, new LogEventArgs(logLevel, m_Time.Elapsed, Thread.CurrentThread.Name, message, data)); } } diff --git a/Ryujinx.Common/Logging/Targets/AsyncLogTargetWrapper.cs b/Ryujinx.Common/Logging/Targets/AsyncLogTargetWrapper.cs index c946b678..43c62d31 100644 --- a/Ryujinx.Common/Logging/Targets/AsyncLogTargetWrapper.cs +++ b/Ryujinx.Common/Logging/Targets/AsyncLogTargetWrapper.cs @@ -57,6 +57,7 @@ namespace Ryujinx.Common.Logging } }); + _messageThread.Name = "Logger.MessageThread"; _messageThread.IsBackground = true; _messageThread.Start(); } diff --git a/Ryujinx.HLE/HOS/Kernel/Common/KTimeManager.cs b/Ryujinx.HLE/HOS/Kernel/Common/KTimeManager.cs index f6a9e6f9..8273520f 100644 --- a/Ryujinx.HLE/HOS/Kernel/Common/KTimeManager.cs +++ b/Ryujinx.HLE/HOS/Kernel/Common/KTimeManager.cs @@ -33,7 +33,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Common _keepRunning = true; - Thread work = new Thread(WaitAndCheckScheduledObjects); + Thread work = new Thread(WaitAndCheckScheduledObjects) + { + Name = "HLE.TimeManager" + }; work.Start(); } diff --git a/Ryujinx.HLE/HOS/Kernel/Threading/HleScheduler.cs b/Ryujinx.HLE/HOS/Kernel/Threading/HleScheduler.cs index 0b951134..1a213b92 100644 --- a/Ryujinx.HLE/HOS/Kernel/Threading/HleScheduler.cs +++ b/Ryujinx.HLE/HOS/Kernel/Threading/HleScheduler.cs @@ -17,7 +17,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading public void StartAutoPreemptionThread() { - Thread preemptionThread = new Thread(PreemptCurrentThread); + Thread preemptionThread = new Thread(PreemptCurrentThread) + { + Name = "HLE.PreemptionThread" + }; _keepPreempting = true; diff --git a/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs b/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs index e1a49a56..c4bd781d 100644 --- a/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs +++ b/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs @@ -159,7 +159,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading is64Bits = true; } - HostThread = new Thread(customHostThreadStart == null ? () => ThreadStart(entrypoint) : customHostThreadStart); + HostThread = new Thread(customHostThreadStart ?? (() => ThreadStart(entrypoint))); Context = new ARMeilleure.State.ExecutionContext(); @@ -185,7 +185,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading ThreadUid = System.GetThreadUid(); - HostThread.Name = $"Host Thread (thread id {ThreadUid})"; + HostThread.Name = $"HLE.HostThread.{ThreadUid}"; _hasBeenInitialized = true; diff --git a/Ryujinx.Profiler/InternalProfile.cs b/Ryujinx.Profiler/InternalProfile.cs index 46984601..03462444 100644 --- a/Ryujinx.Profiler/InternalProfile.cs +++ b/Ryujinx.Profiler/InternalProfile.cs @@ -55,7 +55,10 @@ namespace Ryujinx.Profiler _cleanupRunning = true; // Create cleanup thread. - _cleanupThread = new Thread(CleanupLoop); + _cleanupThread = new Thread(CleanupLoop) + { + Name = "Profiler.CleanupThread" + }; _cleanupThread.Start(); } diff --git a/Ryujinx.Profiler/UI/ProfileWindowManager.cs b/Ryujinx.Profiler/UI/ProfileWindowManager.cs index c6a65a31..13603029 100644 --- a/Ryujinx.Profiler/UI/ProfileWindowManager.cs +++ b/Ryujinx.Profiler/UI/ProfileWindowManager.cs @@ -21,7 +21,10 @@ namespace Ryujinx.Profiler.UI { _profilerRunning = true; _prevTime = 0; - _profileThread = new Thread(ProfileLoop); + _profileThread = new Thread(ProfileLoop) + { + Name = "Profiler.ProfileThread" + }; _profileThread.Start(); } } @@ -60,7 +63,10 @@ namespace Ryujinx.Profiler.UI using (_window = new ProfileWindow()) { // Create thread for render loop - _renderThread = new Thread(RenderLoop); + _renderThread = new Thread(RenderLoop) + { + Name = "Profiler.RenderThread" + }; _renderThread.Start(); while (_profilerRunning) diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index 8e391262..d32ddb5c 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -120,7 +120,10 @@ namespace Ryujinx.Ui Context.MakeCurrent(null); // OpenTK doesn't like sleeps in its thread, to avoid this a renderer thread is created - _renderThread = new Thread(RenderLoop); + _renderThread = new Thread(RenderLoop) + { + Name = "GUI.RenderThread" + }; _renderThread.Start(); diff --git a/Ryujinx/Ui/MainWindow.cs b/Ryujinx/Ui/MainWindow.cs index af7dd524..451df2fd 100644 --- a/Ryujinx/Ui/MainWindow.cs +++ b/Ryujinx/Ui/MainWindow.cs @@ -653,6 +653,7 @@ namespace Ryujinx.Ui } }); + thread.Name = "GUI.FirmwareInstallerThread"; thread.Start(); } else