From 767cdc1f6f6a63ce997fc9476911e2c361f9d402 Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Wed, 20 Feb 2013 20:33:05 -0500 Subject: Pushing missing changes --- MediaBrowser.Controller/Library/ResourcePool.cs | 79 +++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 MediaBrowser.Controller/Library/ResourcePool.cs (limited to 'MediaBrowser.Controller/Library/ResourcePool.cs') diff --git a/MediaBrowser.Controller/Library/ResourcePool.cs b/MediaBrowser.Controller/Library/ResourcePool.cs new file mode 100644 index 000000000..3e4d53204 --- /dev/null +++ b/MediaBrowser.Controller/Library/ResourcePool.cs @@ -0,0 +1,79 @@ +using System; +using System.Threading; + +namespace MediaBrowser.Controller.Library +{ + /// + /// This is just a collection of semaphores to control the number of concurrent executions of various resources + /// + public class ResourcePool : IDisposable + { + /// + /// You tube + /// + public readonly SemaphoreSlim YouTube = new SemaphoreSlim(5, 5); + + /// + /// The trakt + /// + public readonly SemaphoreSlim Trakt = new SemaphoreSlim(5, 5); + + /// + /// The tv db + /// + public readonly SemaphoreSlim TvDb = new SemaphoreSlim(5, 5); + + /// + /// The movie db + /// + public readonly SemaphoreSlim MovieDb = new SemaphoreSlim(5, 5); + + /// + /// The fan art + /// + public readonly SemaphoreSlim FanArt = new SemaphoreSlim(5, 5); + + /// + /// The mb + /// + public readonly SemaphoreSlim Mb = new SemaphoreSlim(5, 5); + + /// + /// Apple doesn't seem to like too many simulataneous requests. + /// + public readonly SemaphoreSlim AppleTrailerVideos = new SemaphoreSlim(1, 1); + + /// + /// The apple trailer images + /// + public readonly SemaphoreSlim AppleTrailerImages = new SemaphoreSlim(1, 1); + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Releases unmanaged and - optionally - managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + protected virtual void Dispose(bool dispose) + { + if (dispose) + { + YouTube.Dispose(); + Trakt.Dispose(); + TvDb.Dispose(); + MovieDb.Dispose(); + FanArt.Dispose(); + Mb.Dispose(); + AppleTrailerVideos.Dispose(); + AppleTrailerImages.Dispose(); + } + } + } +} -- cgit v1.2.3