using System; using System.Threading; namespace MediaBrowser.Common.Kernel { /// /// 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); /// /// The mb /// public readonly SemaphoreSlim Lastfm = 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(); } } } }