diff options
Diffstat (limited to 'src/Ryujinx.Common/Logging/Targets/AsyncLogTargetWrapper.cs')
-rw-r--r-- | src/Ryujinx.Common/Logging/Targets/AsyncLogTargetWrapper.cs | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/Ryujinx.Common/Logging/Targets/AsyncLogTargetWrapper.cs b/src/Ryujinx.Common/Logging/Targets/AsyncLogTargetWrapper.cs index ddc547ac..226318b0 100644 --- a/src/Ryujinx.Common/Logging/Targets/AsyncLogTargetWrapper.cs +++ b/src/Ryujinx.Common/Logging/Targets/AsyncLogTargetWrapper.cs @@ -14,16 +14,16 @@ namespace Ryujinx.Common.Logging.Targets /// <summary> /// Discard the overflowing item /// </summary> - Discard = 1 + Discard = 1, } public class AsyncLogTargetWrapper : ILogTarget { - private ILogTarget _target; + private readonly ILogTarget _target; - private Thread _messageThread; + private readonly Thread _messageThread; - private BlockingCollection<LogEventArgs> _messageQueue; + private readonly BlockingCollection<LogEventArgs> _messageQueue; private readonly int _overflowTimeout; @@ -35,11 +35,12 @@ namespace Ryujinx.Common.Logging.Targets public AsyncLogTargetWrapper(ILogTarget target, int queueLimit, AsyncLogTargetOverflowAction overflowAction) { - _target = target; - _messageQueue = new BlockingCollection<LogEventArgs>(queueLimit); + _target = target; + _messageQueue = new BlockingCollection<LogEventArgs>(queueLimit); _overflowTimeout = overflowAction == AsyncLogTargetOverflowAction.Block ? -1 : 0; - _messageThread = new Thread(() => { + _messageThread = new Thread(() => + { while (!_messageQueue.IsCompleted) { try @@ -55,10 +56,11 @@ namespace Ryujinx.Common.Logging.Targets // on the next iteration. } } - }); - - _messageThread.Name = "Logger.MessageThread"; - _messageThread.IsBackground = true; + }) + { + Name = "Logger.MessageThread", + IsBackground = true, + }; _messageThread.Start(); } @@ -72,8 +74,9 @@ namespace Ryujinx.Common.Logging.Targets public void Dispose() { + GC.SuppressFinalize(this); _messageQueue.CompleteAdding(); _messageThread.Join(); } } -}
\ No newline at end of file +} |