SemaphoreLightTest.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. namespace Renci.SshNet.Tests.Classes.Common
  3. {
  4. /// <summary>
  5. /// Light implementation of SemaphoreSlim.
  6. /// </summary>
  7. public class SemaphoreLightTest
  8. {
  9. /// <summary>
  10. /// Initializes a new instance of the <see cref="SemaphoreLightTest"/> class, specifying
  11. /// the initial number of requests that can be granted concurrently.
  12. /// </summary>
  13. /// <param name="initialCount">The initial number of requests for the semaphore that can be granted concurrently.</param>
  14. /// <exception cref="ArgumentOutOfRangeException"><paramref name="initialCount"/> is a negative number.</exception>
  15. // public SemaphoreLight(int initialCount)
  16. // {
  17. // if (initialCount < 0 )
  18. // throw new ArgumentOutOfRangeException("The initial argument is negative");
  19. // this._currentCount = initialCount;
  20. // }
  21. // /// <summary>
  22. // /// Gets the current count of the <see cref="SemaphoreLight"/>.
  23. // /// </summary>
  24. // public int CurrentCount { get { return this._currentCount; } }
  25. // /// <summary>
  26. // /// Exits the <see cref="SemaphoreLight"/> once.
  27. // /// </summary>
  28. // /// <returns>The previous count of the <see cref="SemaphoreLight"/>.</returns>
  29. // public int Release()
  30. // {
  31. // return this.Release(1);
  32. // }
  33. // /// <summary>
  34. // /// Exits the <see cref="SemaphoreLight"/> a specified number of times.
  35. // /// </summary>
  36. // /// <param name="releaseCount">The number of times to exit the semaphore.</param>
  37. // /// <returns>The previous count of the <see cref="SemaphoreLight"/>.</returns>
  38. // public int Release(int releaseCount)
  39. // {
  40. // var oldCount = this._currentCount;
  41. // lock (this._lock)
  42. // {
  43. // this._currentCount += releaseCount;
  44. // Monitor.Pulse(this._lock);
  45. // }
  46. // return oldCount;
  47. // }
  48. // /// <summary>
  49. // /// Blocks the current thread until it can enter the <see cref="SemaphoreLight"/>.
  50. // /// </summary>
  51. // public void Wait()
  52. // {
  53. // lock (this._lock)
  54. // {
  55. // while (this._currentCount < 1)
  56. // {
  57. // Monitor.Wait(this._lock);
  58. // }
  59. // this._currentCount--;
  60. // Monitor.Pulse(this._lock);
  61. // }
  62. // }
  63. }
  64. }