diff options
| author | LukePulverenti <luke.pulverenti@gmail.com> | 2013-03-04 00:44:04 -0500 |
|---|---|---|
| committer | LukePulverenti <luke.pulverenti@gmail.com> | 2013-03-04 00:44:04 -0500 |
| commit | a11e00b8d5df45342753374843f9152e99f659e5 (patch) | |
| tree | fd7305356ccf62fe5a7f34221969ea62738e0bd2 /MediaBrowser.Common/Kernel | |
| parent | 2ca4b7d03adfa3cc7c9c6a597a11762142d5b34b (diff) | |
| parent | dccba7d1fdff94f14c2a09105b93d6daa602eb4d (diff) | |
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Conflicts:
MediaBrowser.Common/Kernel/ResourcePool.cs
Diffstat (limited to 'MediaBrowser.Common/Kernel')
| -rw-r--r-- | MediaBrowser.Common/Kernel/ResourcePool.cs | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/MediaBrowser.Common/Kernel/ResourcePool.cs b/MediaBrowser.Common/Kernel/ResourcePool.cs new file mode 100644 index 000000000..7a74c60a7 --- /dev/null +++ b/MediaBrowser.Common/Kernel/ResourcePool.cs @@ -0,0 +1,84 @@ +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> + /// The mb + /// </summary> + public readonly SemaphoreSlim Lastfm = 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(); + } + } + } +} |
