mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Remove Lazy
This commit is contained in:
parent
74f211960a
commit
2b6b2cbf31
@ -39,7 +39,7 @@ namespace MediaBrowser.Controller.BaseItemManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Lazy<SemaphoreSlim> MetadataRefreshThrottler { get; private set; }
|
public SemaphoreSlim MetadataRefreshThrottler { get; private set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool IsMetadataFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name)
|
public bool IsMetadataFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name)
|
||||||
@ -108,10 +108,7 @@ namespace MediaBrowser.Controller.BaseItemManager
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void SetupMetadataThrottler()
|
private void SetupMetadataThrottler()
|
||||||
{
|
{
|
||||||
if (MetadataRefreshThrottler == null || MetadataRefreshThrottler.IsValueCreated)
|
MetadataRefreshThrottler = new SemaphoreSlim(_metadataRefreshConcurrency);
|
||||||
{
|
|
||||||
MetadataRefreshThrottler = new Lazy<SemaphoreSlim>(() => new SemaphoreSlim(_metadataRefreshConcurrency));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -13,7 +13,7 @@ namespace MediaBrowser.Controller.BaseItemManager
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the semaphore used to limit the amount of concurrent metadata refreshes.
|
/// Gets the semaphore used to limit the amount of concurrent metadata refreshes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Lazy<SemaphoreSlim> MetadataRefreshThrottler { get; }
|
SemaphoreSlim MetadataRefreshThrottler { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Is metadata fetcher enabled.
|
/// Is metadata fetcher enabled.
|
||||||
|
@ -1175,7 +1175,10 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
|
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
|
||||||
public async Task RunMetadataRefresh(Func<Task> action, CancellationToken cancellationToken)
|
public async Task RunMetadataRefresh(Func<Task> action, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await _baseItemManager.MetadataRefreshThrottler.Value.WaitAsync(cancellationToken).ConfigureAwait(false);
|
// create a variable for this since it is possible MetadataRefreshThrottler could change due to a config update during a scan
|
||||||
|
var metadataRefreshThrottler = _baseItemManager.MetadataRefreshThrottler;
|
||||||
|
|
||||||
|
await metadataRefreshThrottler.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -1183,7 +1186,7 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
_baseItemManager.MetadataRefreshThrottler.Value.Release();
|
metadataRefreshThrottler.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user