Name all threads (#886)

* Name all threads

Close #874

* use ThreadName instead of ThreadId in Logging
This commit is contained in:
Ac_K 2020-01-13 01:21:54 +01:00 committed by Thog
parent f0055482fd
commit 5facc0c07f
13 changed files with 60 additions and 29 deletions

View file

@ -58,9 +58,12 @@ namespace ARMeilleure.Translation
{ {
if (Interlocked.Increment(ref _threadCount) == 1) 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(); backgroundTranslatorThread.Start();
} }

View file

@ -70,7 +70,10 @@ namespace Ryujinx.Audio
_context = new AudioContext(); _context = new AudioContext();
_tracks = new ConcurrentDictionary<int, OpenALAudioTrack>(); _tracks = new ConcurrentDictionary<int, OpenALAudioTrack>();
_keepPolling = true; _keepPolling = true;
_audioPollerThread = new Thread(AudioPollerWork); _audioPollerThread = new Thread(AudioPollerWork)
{
Name = "Audio.PollerThread"
};
_audioPollerThread.Start(); _audioPollerThread.Start();
} }

View file

@ -18,8 +18,13 @@ namespace Ryujinx.Common.Logging
sb.AppendFormat(@"{0:hh\:mm\:ss\.fff}", args.Time); sb.AppendFormat(@"{0:hh\:mm\:ss\.fff}", args.Time);
sb.Append(" | "); sb.Append(" | ");
sb.AppendFormat("{0:d4}", args.ThreadId);
if (args.ThreadName != null)
{
sb.Append(args.ThreadName);
sb.Append(' '); sb.Append(' ');
}
sb.Append(args.Message); sb.Append(args.Message);
if (args.Data != null) if (args.Data != null)

View file

@ -6,24 +6,24 @@ namespace Ryujinx.Common.Logging
{ {
public LogLevel Level { get; private set; } public LogLevel Level { get; private set; }
public TimeSpan Time { get; private set; } public TimeSpan Time { get; private set; }
public int ThreadId { get; private set; } public string ThreadName { get; private set; }
public string Message { get; private set; } public string Message { get; private set; }
public object Data { 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; Level = level;
Time = time; Time = time;
ThreadId = threadId; ThreadName = threadName;
Message = message; 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; Level = level;
Time = time; Time = time;
ThreadId = threadId; ThreadName = threadName;
Message = message; Message = message;
Data = data; Data = data;
} }

View file

@ -155,7 +155,7 @@ namespace Ryujinx.Common.Logging
{ {
if (m_EnabledLevels[(int)logLevel] && m_EnabledClasses[(int)logClass]) 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]) 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));
} }
} }

View file

@ -57,6 +57,7 @@ namespace Ryujinx.Common.Logging
} }
}); });
_messageThread.Name = "Logger.MessageThread";
_messageThread.IsBackground = true; _messageThread.IsBackground = true;
_messageThread.Start(); _messageThread.Start();
} }

View file

@ -33,7 +33,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
_keepRunning = true; _keepRunning = true;
Thread work = new Thread(WaitAndCheckScheduledObjects); Thread work = new Thread(WaitAndCheckScheduledObjects)
{
Name = "HLE.TimeManager"
};
work.Start(); work.Start();
} }

View file

@ -17,7 +17,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
public void StartAutoPreemptionThread() public void StartAutoPreemptionThread()
{ {
Thread preemptionThread = new Thread(PreemptCurrentThread); Thread preemptionThread = new Thread(PreemptCurrentThread)
{
Name = "HLE.PreemptionThread"
};
_keepPreempting = true; _keepPreempting = true;

View file

@ -159,7 +159,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
is64Bits = true; is64Bits = true;
} }
HostThread = new Thread(customHostThreadStart == null ? () => ThreadStart(entrypoint) : customHostThreadStart); HostThread = new Thread(customHostThreadStart ?? (() => ThreadStart(entrypoint)));
Context = new ARMeilleure.State.ExecutionContext(); Context = new ARMeilleure.State.ExecutionContext();
@ -185,7 +185,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
ThreadUid = System.GetThreadUid(); ThreadUid = System.GetThreadUid();
HostThread.Name = $"Host Thread (thread id {ThreadUid})"; HostThread.Name = $"HLE.HostThread.{ThreadUid}";
_hasBeenInitialized = true; _hasBeenInitialized = true;

View file

@ -55,7 +55,10 @@ namespace Ryujinx.Profiler
_cleanupRunning = true; _cleanupRunning = true;
// Create cleanup thread. // Create cleanup thread.
_cleanupThread = new Thread(CleanupLoop); _cleanupThread = new Thread(CleanupLoop)
{
Name = "Profiler.CleanupThread"
};
_cleanupThread.Start(); _cleanupThread.Start();
} }

View file

@ -21,7 +21,10 @@ namespace Ryujinx.Profiler.UI
{ {
_profilerRunning = true; _profilerRunning = true;
_prevTime = 0; _prevTime = 0;
_profileThread = new Thread(ProfileLoop); _profileThread = new Thread(ProfileLoop)
{
Name = "Profiler.ProfileThread"
};
_profileThread.Start(); _profileThread.Start();
} }
} }
@ -60,7 +63,10 @@ namespace Ryujinx.Profiler.UI
using (_window = new ProfileWindow()) using (_window = new ProfileWindow())
{ {
// Create thread for render loop // Create thread for render loop
_renderThread = new Thread(RenderLoop); _renderThread = new Thread(RenderLoop)
{
Name = "Profiler.RenderThread"
};
_renderThread.Start(); _renderThread.Start();
while (_profilerRunning) while (_profilerRunning)

View file

@ -120,7 +120,10 @@ namespace Ryujinx.Ui
Context.MakeCurrent(null); Context.MakeCurrent(null);
// OpenTK doesn't like sleeps in its thread, to avoid this a renderer thread is created // 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(); _renderThread.Start();

View file

@ -653,6 +653,7 @@ namespace Ryujinx.Ui
} }
}); });
thread.Name = "GUI.FirmwareInstallerThread";
thread.Start(); thread.Start();
} }
else else