diff options
| author | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-26 16:53:57 -0500 |
|---|---|---|
| committer | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-26 16:53:57 -0500 |
| commit | 939a3aab4526ff072a2caeb140fe014333b234c5 (patch) | |
| tree | fec1e08594ae035ff8cfd36b2389f6441d7d679c /MediaBrowser.Common/Kernel/ResourcePool.cs | |
| parent | fb92f47abd1258b776e0c7c51b5e0fb7db1fae9b (diff) | |
| parent | 4c1c7178241b664ccbf6afcef164fbf1e5128529 (diff) | |
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Diffstat (limited to 'MediaBrowser.Common/Kernel/ResourcePool.cs')
| -rw-r--r-- | MediaBrowser.Common/Kernel/ResourcePool.cs | 79 |
1 files changed, 79 insertions, 0 deletions
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(); + } + } + } +} |
