mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-12-26 09:26:15 +00:00
move to new System.Threading.Lock type for better performance
This commit is contained in:
parent
b89877554c
commit
2614fecf8d
|
@ -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>();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace MediaBrowser.Controller.Net
|
|||
SingleWriter = false
|
||||
});
|
||||
|
||||
private readonly object _activeConnectionsLock = new();
|
||||
private readonly Lock _activeConnectionsLock = new();
|
||||
|
||||
/// <summary>
|
||||
/// The _active connections.
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue