1
0

SmartThreadPool.ThreadEntry.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using Amib.Threading.Internal;
  3. namespace Amib.Threading
  4. {
  5. public partial class SmartThreadPool
  6. {
  7. #region ThreadEntry class
  8. internal class ThreadEntry
  9. {
  10. /// <summary>
  11. /// The thread creation time
  12. /// The value is stored as UTC value.
  13. /// </summary>
  14. private readonly DateTime _creationTime;
  15. /// <summary>
  16. /// The last time this thread has been running
  17. /// It is updated by IAmAlive() method
  18. /// The value is stored as UTC value.
  19. /// </summary>
  20. private DateTime _lastAliveTime;
  21. /// <summary>
  22. /// A reference from each thread in the thread pool to its SmartThreadPool
  23. /// object container.
  24. /// With this variable a thread can know whatever it belongs to a
  25. /// SmartThreadPool.
  26. /// </summary>
  27. private readonly SmartThreadPool _associatedSmartThreadPool;
  28. /// <summary>
  29. /// A reference to the current work item a thread from the thread pool
  30. /// is executing.
  31. /// </summary>
  32. public WorkItem CurrentWorkItem { get; set; }
  33. public ThreadEntry(SmartThreadPool stp)
  34. {
  35. _associatedSmartThreadPool = stp;
  36. _creationTime = DateTime.UtcNow;
  37. _lastAliveTime = DateTime.MinValue;
  38. }
  39. public SmartThreadPool AssociatedSmartThreadPool
  40. {
  41. get { return _associatedSmartThreadPool; }
  42. }
  43. public void IAmAlive()
  44. {
  45. _lastAliveTime = DateTime.UtcNow;
  46. }
  47. }
  48. #endregion
  49. }
  50. }