aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Common/Kernel')
-rw-r--r--MediaBrowser.Common/Kernel/BaseKernel.cs7
-rw-r--r--MediaBrowser.Common/Kernel/IKernel.cs6
-rw-r--r--MediaBrowser.Common/Kernel/ResourcePool.cs79
3 files changed, 92 insertions, 0 deletions
diff --git a/MediaBrowser.Common/Kernel/BaseKernel.cs b/MediaBrowser.Common/Kernel/BaseKernel.cs
index 184cef98b..962c740c3 100644
--- a/MediaBrowser.Common/Kernel/BaseKernel.cs
+++ b/MediaBrowser.Common/Kernel/BaseKernel.cs
@@ -455,5 +455,12 @@ namespace MediaBrowser.Common.Kernel
{
return GetXmlConfiguration(typeof(T), path) as T;
}
+
+ /// <summary>
+ /// Limits simultaneous access to various resources
+ /// </summary>
+ /// <value>The resource pools.</value>
+ public ResourcePool ResourcePools { get; set; }
+
}
}
diff --git a/MediaBrowser.Common/Kernel/IKernel.cs b/MediaBrowser.Common/Kernel/IKernel.cs
index a4ff16afb..dce744c0a 100644
--- a/MediaBrowser.Common/Kernel/IKernel.cs
+++ b/MediaBrowser.Common/Kernel/IKernel.cs
@@ -117,5 +117,11 @@ namespace MediaBrowser.Common.Kernel
/// <param name="path">The path.</param>
/// <returns>System.Object.</returns>
object GetXmlConfiguration(Type type, string path);
+
+ /// <summary>
+ /// Limits simultaneous access to various resources
+ /// </summary>
+ /// <value>The resource pools.</value>
+ ResourcePool ResourcePools { get; set; }
}
}
diff --git a/MediaBrowser.Common/Kernel/ResourcePool.cs b/MediaBrowser.Common/Kernel/ResourcePool.cs
new file mode 100644
index 000000000..8a2ab8af8
--- /dev/null
+++ b/MediaBrowser.Common/Kernel/ResourcePool.cs
@@ -0,0 +1,79 @@
+using System;
+using System.Threading;
+
+namespace MediaBrowser.Common.Kernel
+{
+ /// <summary>
+ /// This is just a collection of semaphores to control the number of concurrent executions of various resources
+ /// </summary>
+ public class ResourcePool : IDisposable
+ {
+ /// <summary>
+ /// You tube
+ /// </summary>
+ public readonly SemaphoreSlim YouTube = new SemaphoreSlim(5, 5);
+
+ /// <summary>
+ /// The trakt
+ /// </summary>
+ public readonly SemaphoreSlim Trakt = new SemaphoreSlim(5, 5);
+
+ /// <summary>
+ /// The tv db
+ /// </summary>
+ public readonly SemaphoreSlim TvDb = new SemaphoreSlim(5, 5);
+
+ /// <summary>
+ /// The movie db
+ /// </summary>
+ public readonly SemaphoreSlim MovieDb = new SemaphoreSlim(5, 5);
+
+ /// <summary>
+ /// The fan art
+ /// </summary>
+ public readonly SemaphoreSlim FanArt = new SemaphoreSlim(5, 5);
+
+ /// <summary>
+ /// The mb
+ /// </summary>
+ public readonly SemaphoreSlim Mb = new SemaphoreSlim(5, 5);
+
+ /// <summary>
+ /// Apple doesn't seem to like too many simulataneous requests.
+ /// </summary>
+ public readonly SemaphoreSlim AppleTrailerVideos = new SemaphoreSlim(1, 1);
+
+ /// <summary>
+ /// The apple trailer images
+ /// </summary>
+ public readonly SemaphoreSlim AppleTrailerImages = new SemaphoreSlim(1, 1);
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ /// <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)
+ {
+ YouTube.Dispose();
+ Trakt.Dispose();
+ TvDb.Dispose();
+ MovieDb.Dispose();
+ FanArt.Dispose();
+ Mb.Dispose();
+ AppleTrailerVideos.Dispose();
+ AppleTrailerImages.Dispose();
+ }
+ }
+ }
+}