move to new System.Threading.Lock type for better performance

This commit is contained in:
Daniyar Alpyspayev
2024-12-12 18:10:06 +05:00
parent b89877554c
commit 2614fecf8d
20 changed files with 30 additions and 26 deletions

View File

@@ -6,6 +6,7 @@ using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Threading;
using Jellyfin.Extensions.Json;
using Microsoft.Extensions.Logging;
@@ -15,7 +16,7 @@ namespace Jellyfin.LiveTv.Timers
where T : class
{
private readonly string _dataPath;
private readonly object _fileDataLock = new object();
private readonly Lock _fileDataLock = new();
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
private T[]? _items;

View File

@@ -27,7 +27,7 @@ public class NetworkManager : INetworkManager, IDisposable
/// <summary>
/// Threading lock for network properties.
/// </summary>
private readonly object _initLock;
private readonly Lock _initLock;
private readonly ILogger<NetworkManager> _logger;
@@ -35,7 +35,7 @@ public class NetworkManager : INetworkManager, IDisposable
private readonly IConfiguration _startupConfig;
private readonly object _networkEventLock;
private readonly Lock _networkEventLock;
/// <summary>
/// Holds the published server URLs and the IPs to use them on.
@@ -93,7 +93,7 @@ public class NetworkManager : INetworkManager, IDisposable
_interfaces = new List<IPData>();
_macAddresses = new List<PhysicalAddress>();
_publishedServerUrls = new List<PublishedServerUriOverride>();
_networkEventLock = new object();
_networkEventLock = new();
_remoteAddressFilter = new List<IPNetwork>();
_ = bool.TryParse(startupConfig[DetectNetworkChangeKey], out var detectNetworkChange);