diff options
Diffstat (limited to 'MediaBrowser.Common')
| -rw-r--r-- | MediaBrowser.Common/Extensions/NamedLock.cs | 97 | ||||
| -rw-r--r-- | MediaBrowser.Common/IO/FileSystemRepository.cs | 25 | ||||
| -rw-r--r-- | MediaBrowser.Common/MediaBrowser.Common.csproj | 1 |
3 files changed, 0 insertions, 123 deletions
diff --git a/MediaBrowser.Common/Extensions/NamedLock.cs b/MediaBrowser.Common/Extensions/NamedLock.cs deleted file mode 100644 index d0164c70d..000000000 --- a/MediaBrowser.Common/Extensions/NamedLock.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace MediaBrowser.Common.Extensions -{ - /// <summary> - /// Class NamedLock - /// </summary> - public class NamedLock : IDisposable - { - /// <summary> - /// The _locks - /// </summary> - private readonly Dictionary<string, SemaphoreSlim> _locks = new Dictionary<string, SemaphoreSlim>(); - - /// <summary> - /// Waits the async. - /// </summary> - /// <param name="name">The name.</param> - /// <returns>Task.</returns> - public Task WaitAsync(string name) - { - return GetLock(name).WaitAsync(); - } - - /// <summary> - /// Releases the specified name. - /// </summary> - /// <param name="name">The name.</param> - public void Release(string name) - { - SemaphoreSlim semaphore; - - if (_locks.TryGetValue(name, out semaphore)) - { - semaphore.Release(); - } - } - - /// <summary> - /// Gets the lock. - /// </summary> - /// <param name="filename">The filename.</param> - /// <returns>System.Object.</returns> - private SemaphoreSlim GetLock(string filename) - { - SemaphoreSlim fileLock; - lock (_locks) - { - if (!_locks.TryGetValue(filename, out fileLock)) - { - fileLock = new SemaphoreSlim(1,1); - _locks[filename] = fileLock; - } - } - return fileLock; - } - - /// <summary> - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// </summary> - public void Dispose() - { - Dispose(true); - } - - /// <summary> - /// Releases unmanaged and - optionally - managed resources. - /// </summary> - /// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> - protected virtual void Dispose(bool dispose) - { - if (dispose) - { - DisposeLocks(); - } - } - - /// <summary> - /// Disposes the locks. - /// </summary> - private void DisposeLocks() - { - lock (_locks) - { - foreach (var semaphore in _locks.Values) - { - semaphore.Dispose(); - } - - _locks.Clear(); - } - } - } -} diff --git a/MediaBrowser.Common/IO/FileSystemRepository.cs b/MediaBrowser.Common/IO/FileSystemRepository.cs index 24ad04a92..3a4987a94 100644 --- a/MediaBrowser.Common/IO/FileSystemRepository.cs +++ b/MediaBrowser.Common/IO/FileSystemRepository.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Concurrent; using System.IO; -using System.Threading.Tasks; namespace MediaBrowser.Common.IO { @@ -19,11 +18,6 @@ namespace MediaBrowser.Common.IO private readonly ConcurrentDictionary<string, string> _subFolderPaths = new ConcurrentDictionary<string, string>(); /// <summary> - /// The _file locks - /// </summary> - private readonly NamedLock _fileLocks = new NamedLock(); - - /// <summary> /// Gets or sets the path. /// </summary> /// <value>The path.</value> @@ -171,24 +165,6 @@ namespace MediaBrowser.Common.IO } /// <summary> - /// Waits for lock. - /// </summary> - /// <param name="resourcePath">The resource path.</param> - public Task WaitForLockAsync(string resourcePath) - { - return _fileLocks.WaitAsync(resourcePath); - } - - /// <summary> - /// Releases the lock. - /// </summary> - /// <param name="resourcePath">The resource path.</param> - public void ReleaseLock(string resourcePath) - { - _fileLocks.Release(resourcePath); - } - - /// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() @@ -204,7 +180,6 @@ namespace MediaBrowser.Common.IO { if (dispose) { - _fileLocks.Dispose(); } } } diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj index a8fc4564c..e9dda6bb7 100644 --- a/MediaBrowser.Common/MediaBrowser.Common.csproj +++ b/MediaBrowser.Common/MediaBrowser.Common.csproj @@ -61,7 +61,6 @@ <Compile Include="Events\EventHelper.cs" /> <Compile Include="Extensions\BaseExtensions.cs" /> <Compile Include="Events\GenericEventArgs.cs" /> - <Compile Include="Extensions\NamedLock.cs" /> <Compile Include="Extensions\ResourceNotFoundException.cs" /> <Compile Include="IO\FileSystemRepository.cs" /> <Compile Include="IO\IIsoManager.cs" /> |
