RuntimeThread.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using System;
  2. using System.Threading;
  3. using System.Runtime.ConstrainedExecution;
  4. using System.Runtime.CompilerServices;
  5. namespace Internal.Runtime.Augments
  6. {
  7. public partial class RuntimeThread : CriticalFinalizerObject
  8. {
  9. // Note: Magic number copied from CoreRT's RuntimeThread.cs. See the original source code for an explanation.
  10. internal static readonly int OptimalMaxSpinWaitsPerSpinIteration = 64;
  11. readonly Thread thread;
  12. RuntimeThread (Thread t)
  13. {
  14. thread = t;
  15. }
  16. public bool IsBackground {
  17. get { throw new NotImplementedException (); }
  18. set { }
  19. }
  20. public static RuntimeThread CurrentThread => throw new NotImplementedException ();
  21. internal static ulong CurrentOSThreadId {
  22. get {
  23. throw new NotImplementedException ();
  24. }
  25. }
  26. public extern bool IsThreadPoolThread
  27. {
  28. [MethodImpl (MethodImplOptions.InternalCall)]
  29. get;
  30. }
  31. public int ManagedThreadId => AsThread ().ManagedThreadId;
  32. public string Name {
  33. get {
  34. return AsThread ().Name;
  35. }
  36. set {
  37. AsThread ().Name = value;
  38. }
  39. }
  40. public ThreadPriority Priority {
  41. get {
  42. throw new NotImplementedException ();
  43. }
  44. set {
  45. }
  46. }
  47. public ThreadState ThreadState {
  48. get {
  49. throw new NotImplementedException ();
  50. }
  51. }
  52. public extern bool IsAlive {
  53. [MethodImpl(MethodImplOptions.InternalCall)]
  54. get;
  55. }
  56. public static bool Yield () => Thread.Yield ();
  57. public void Interrupt ()
  58. {
  59. throw new NotImplementedException ();
  60. }
  61. private Thread AsThread ()
  62. {
  63. throw new NotImplementedException ();
  64. }
  65. public static RuntimeThread Create (ThreadStart start) => throw new NotImplementedException ();
  66. public static RuntimeThread Create (ThreadStart start, int maxStackSize) => throw new NotImplementedException ();
  67. public static RuntimeThread Create (ParameterizedThreadStart start) => throw new NotImplementedException ();
  68. public static RuntimeThread Create (ParameterizedThreadStart start, int maxStackSize) => throw new NotImplementedException ();
  69. public static int GetCurrentProcessorId ()
  70. {
  71. // TODO: Implement correctly
  72. return 1;
  73. }
  74. public static bool SpinWait (int iterations)
  75. {
  76. Thread.SpinWait (iterations);
  77. return true;
  78. }
  79. public static void Sleep (int millisecondsTimeout) => Thread.Sleep (millisecondsTimeout);
  80. public void Start () => throw new NotImplementedException ();
  81. public void Start (object parameter) => throw new NotImplementedException ();
  82. public void Join () => JoinInternal (Timeout.Infinite);
  83. public bool Join (int millisecondsTimeout) => JoinInternal (millisecondsTimeout);
  84. private bool JoinInternal (int millisecondsTimeout)
  85. {
  86. throw new NotImplementedException ();
  87. }
  88. }
  89. }