tthread.inc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. {
  2. This file is part of the Free Component Library (FCL)
  3. Copyright (c) 1999-2002 by the Free Pascal development team
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. {****************************************************************************}
  11. {* TThread *}
  12. {****************************************************************************}
  13. {$WARNING This file is only a stub, and will not work!}
  14. const
  15. ThreadCount: longint = 0;
  16. (* Implementation of exported functions *)
  17. procedure AddThread (T: TThread);
  18. begin
  19. Inc (ThreadCount);
  20. end;
  21. procedure RemoveThread (T: TThread);
  22. begin
  23. Dec (ThreadCount);
  24. end;
  25. procedure TThread.CallOnTerminate;
  26. begin
  27. FOnTerminate (Self);
  28. end;
  29. function TThread.GetPriority: TThreadPriority;
  30. begin
  31. result := tpNormal;
  32. end;
  33. procedure TThread.SetPriority(Value: TThreadPriority);
  34. begin
  35. end;
  36. procedure TThread.SetSuspended(Value: Boolean);
  37. begin
  38. if Value <> FSuspended then
  39. begin
  40. if Value then Suspend else Resume;
  41. end;
  42. end;
  43. procedure TThread.DoTerminate;
  44. begin
  45. if Assigned (FOnTerminate) then Synchronize (@CallOnTerminate);
  46. end;
  47. constructor TThread.Create(CreateSuspended: Boolean;
  48. const StackSize: SizeUInt = DefaultStackSize);
  49. var
  50. Flags: cardinal;
  51. begin
  52. inherited Create;
  53. AddThread (Self);
  54. end;
  55. destructor TThread.Destroy;
  56. begin
  57. if not FFinished and not Suspended then
  58. begin
  59. Terminate;
  60. WaitFor;
  61. end;
  62. end;
  63. procedure TThread.Resume;
  64. begin
  65. end;
  66. procedure TThread.Suspend;
  67. begin
  68. end;
  69. procedure TThread.Terminate;
  70. begin
  71. FTerminated := true;
  72. end;
  73. function TThread.WaitFor: Integer;
  74. begin
  75. result := -1;
  76. end;