Merge pull request #13213 from Ich1goSan/master
Some checks are pending
CodeQL / Analyze (csharp) (push) Waiting to run
OpenAPI / OpenAPI - HEAD (push) Waiting to run
OpenAPI / OpenAPI - BASE (push) Waiting to run
OpenAPI / OpenAPI - Difference (push) Blocked by required conditions
OpenAPI / OpenAPI - Publish Unstable Spec (push) Blocked by required conditions
OpenAPI / OpenAPI - Publish Stable Spec (push) Blocked by required conditions
Tests / run-tests (macos-latest) (push) Waiting to run
Tests / run-tests (ubuntu-latest) (push) Waiting to run
Tests / run-tests (windows-latest) (push) Waiting to run
Project Automation / Project board (push) Waiting to run
Merge Conflict Labeler / Labeling (push) Waiting to run

move to new System.Threading.Lock type for better performance
This commit is contained in:
Bond-009 2024-12-20 22:15:45 +01:00 committed by GitHub
commit c4d4419800
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 30 additions and 26 deletions

View file

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Events;
using MediaBrowser.Common.Extensions;
@ -19,7 +20,7 @@ namespace Emby.Server.Implementations.AppBase
public abstract class BaseConfigurationManager : IConfigurationManager
{
private readonly ConcurrentDictionary<string, object> _configurations = new();
private readonly object _configurationSyncLock = new();
private readonly Lock _configurationSyncLock = new();
private ConfigurationStore[] _configurationStores = Array.Empty<ConfigurationStore>();
private IConfigurationFactory[] _configurationFactories = Array.Empty<IConfigurationFactory>();

View file

@ -4,6 +4,7 @@ using System;
using System.Globalization;
using System.IO;
using System.Text;
using System.Threading;
using MediaBrowser.Common.Configuration;
using Microsoft.Extensions.Logging;
@ -13,7 +14,7 @@ namespace Emby.Server.Implementations.Devices
{
private readonly IApplicationPaths _appPaths;
private readonly ILogger<DeviceId> _logger;
private readonly object _syncLock = new object();
private readonly Lock _syncLock = new();
private string? _id;

View file

@ -34,7 +34,7 @@ public sealed class LibraryChangedNotifier : IHostedService, IDisposable
private readonly IUserManager _userManager;
private readonly ILogger<LibraryChangedNotifier> _logger;
private readonly object _libraryChangedSyncLock = new();
private readonly Lock _libraryChangedSyncLock = new();
private readonly List<Folder> _foldersAddedTo = new();
private readonly List<Folder> _foldersRemovedFrom = new();
private readonly List<BaseItem> _itemsAdded = new();

View file

@ -24,7 +24,7 @@ namespace Emby.Server.Implementations.EntryPoints
private readonly IUserManager _userManager;
private readonly Dictionary<Guid, List<BaseItem>> _changedItems = new();
private readonly object _syncLock = new();
private readonly Lock _syncLock = new();
private Timer? _updateTimer;

View file

@ -18,8 +18,8 @@ namespace Emby.Server.Implementations.IO
private readonly ILibraryManager _libraryManager;
private readonly IServerConfigurationManager _configurationManager;
private readonly List<string> _affectedPaths = new List<string>();
private readonly object _timerLock = new object();
private readonly List<string> _affectedPaths = new();
private readonly Lock _timerLock = new();
private Timer? _timer;
private bool _disposed;

View file

@ -81,8 +81,8 @@ namespace Emby.Server.Implementations.Library
/// <summary>
/// The _root folder sync lock.
/// </summary>
private readonly object _rootFolderSyncLock = new object();
private readonly object _userRootFolderSyncLock = new object();
private readonly Lock _rootFolderSyncLock = new();
private readonly Lock _userRootFolderSyncLock = new();
private readonly TimeSpan _viewRefreshInterval = TimeSpan.FromHours(24);

View file

@ -27,7 +27,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
private readonly IApplicationPaths _applicationPaths;
private readonly ILogger _logger;
private readonly ITaskManager _taskManager;
private readonly object _lastExecutionResultSyncLock = new();
private readonly Lock _lastExecutionResultSyncLock = new();
private bool _readFromFile;
private TaskResult _lastExecutionResult;
private Task _currentTask;

View file

@ -41,7 +41,7 @@ namespace Emby.Server.Implementations.Session
/// <summary>
/// Lock used for accessing the WebSockets watchlist.
/// </summary>
private readonly object _webSocketsLock = new object();
private readonly Lock _webSocketsLock = new();
private readonly ISessionManager _sessionManager;
private readonly ILogger<SessionWebSocketListener> _logger;

View file

@ -67,7 +67,7 @@ namespace Emby.Server.Implementations.SyncPlay
/// <remarks>
/// This lock has priority on locks made on <see cref="Group"/>.
/// </remarks>
private readonly object _groupsLock = new object();
private readonly Lock _groupsLock = new();
private bool _disposed = false;

View file

@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.Updates
/// </summary>
/// <value>The application host.</value>
private readonly IServerApplicationHost _applicationHost;
private readonly object _currentInstallationsLock = new object();
private readonly Lock _currentInstallationsLock = new();
/// <summary>
/// The current installations.

View file

@ -4,6 +4,7 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Model.Plugins;
using MediaBrowser.Model.Serialization;
@ -20,12 +21,12 @@ namespace MediaBrowser.Common.Plugins
/// <summary>
/// The configuration sync lock.
/// </summary>
private readonly object _configurationSyncLock = new object();
private readonly Lock _configurationSyncLock = new();
/// <summary>
/// The configuration save lock.
/// </summary>
private readonly object _configurationSaveLock = new object();
private readonly Lock _configurationSaveLock = new();
/// <summary>
/// The configuration.

View file

@ -23,7 +23,7 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
public class AggregateFolder : Folder
{
private readonly object _childIdsLock = new object();
private readonly Lock _childIdsLock = new();
/// <summary>
/// The _virtual children.

View file

@ -21,7 +21,7 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
public class UserRootFolder : Folder
{
private readonly object _childIdsLock = new object();
private readonly Lock _childIdsLock = new();
private List<Guid> _childrenIds = null;
/// <summary>

View file

@ -12,8 +12,8 @@ namespace MediaBrowser.Controller.MediaEncoding;
public sealed class TranscodingJob : IDisposable
{
private readonly ILogger<TranscodingJob> _logger;
private readonly object _processLock = new();
private readonly object _timerLock = new();
private readonly Lock _processLock = new();
private readonly Lock _timerLock = new();
private Timer? _killTimer;

View file

@ -33,7 +33,7 @@ namespace MediaBrowser.Controller.Net
SingleWriter = false
});
private readonly object _activeConnectionsLock = new();
private readonly Lock _activeConnectionsLock = new();
/// <summary>
/// The _active connections.

View file

@ -25,7 +25,7 @@ namespace MediaBrowser.Controller.Session
private readonly ISessionManager _sessionManager;
private readonly ILogger _logger;
private readonly object _progressLock = new();
private readonly Lock _progressLock = new();
private Timer _progressTimer;
private PlaybackProgressInfo _lastProgressInfo;

View file

@ -62,7 +62,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
private readonly AsyncNonKeyedLocker _thumbnailResourcePool;
private readonly object _runningProcessesLock = new object();
private readonly Lock _runningProcessesLock = new();
private readonly List<ProcessWrapper> _runningProcesses = new List<ProcessWrapper>();
// MediaEncoder is registered as a Singleton

View file

@ -48,7 +48,7 @@ namespace MediaBrowser.Providers.Manager
/// </summary>
public class ProviderManager : IProviderManager, IDisposable
{
private readonly object _refreshQueueLock = new();
private readonly Lock _refreshQueueLock = new();
private readonly ILogger<ProviderManager> _logger;
private readonly IHttpClientFactory _httpClientFactory;
private readonly ILibraryMonitor _libraryMonitor;

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);