threadh.inc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Run time library.
  4. Copyright (c) 2000 by the Free Pascal development team
  5. This File contains the OS indenpendend declartions for multi
  6. threading support in FPC
  7. See the File COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. const
  14. DefaultStackSize = 32768; { including 16384 margin for stackchecking }
  15. type
  16. TThreadFunc = function(parameter : pointer) : longint;
  17. {*****************************************************************************
  18. Multithread Handling
  19. *****************************************************************************}
  20. function BeginThread(sa : Pointer;stacksize : dword;
  21. ThreadFunction : tthreadfunc;p : pointer;creationFlags : dword;
  22. var ThreadId : DWord) : DWord;
  23. { Delphi uses a longint for threadid }
  24. function BeginThread(sa : Pointer;stacksize : dword;
  25. ThreadFunction : tthreadfunc;p : pointer;creationFlags : dword;
  26. var ThreadId : Longint) : DWord;
  27. { add some simplfied forms which make lifer easier and porting }
  28. { to other OSes too ... }
  29. function BeginThread(ThreadFunction : tthreadfunc) : DWord;
  30. function BeginThread(ThreadFunction : tthreadfunc;p : pointer) : DWord;
  31. function BeginThread(ThreadFunction : tthreadfunc;p : pointer; var ThreadId : DWord) : DWord;
  32. function BeginThread(ThreadFunction : tthreadfunc;p : pointer; var ThreadId : Longint) : DWord;
  33. procedure EndThread(ExitCode : DWord);
  34. procedure EndThread;
  35. {some thread support functions}
  36. function SuspendThread (threadHandle : dword) : dword;
  37. function ResumeThread (threadHandle : dword) : dword;
  38. procedure ThreadSwitch; {give time to other threads}
  39. function KillThread (threadHandle : dword) : dword;
  40. function WaitForThreadTerminate (threadHandle : dword; TimeoutMs : longint) : dword; {0=no timeout}
  41. function ThreadSetPriority (threadHandle : dword; Prio: longint): boolean; {-15..+15, 0=normal}
  42. function ThreadGetPriority (threadHandle : dword): Integer;
  43. function GetCurrentThreadId : dword;
  44. { this allows to do a lot of things in MT safe way }
  45. { it is also used to make the heap management }
  46. { thread safe }
  47. procedure InitCriticalSection(var cs : TRTLCriticalSection);
  48. procedure DoneCriticalsection(var cs : TRTLCriticalSection);
  49. procedure EnterCriticalsection(var cs : TRTLCriticalSection);
  50. procedure LeaveCriticalsection(var cs : TRTLCriticalSection);
  51. {
  52. $Log$
  53. Revision 1.11 2003-10-01 21:00:09 peter
  54. * GetCurrentThreadHandle renamed to GetCurrentThreadId
  55. Revision 1.10 2003/03/27 17:14:27 armin
  56. * more platform independent thread routines, needs to be implemented for unix
  57. Revision 1.9 2002/10/16 19:04:27 michael
  58. + More system-independent thread routines
  59. Revision 1.8 2002/10/14 19:39:17 peter
  60. * threads unit added for thread support
  61. Revision 1.7 2002/09/07 15:07:46 peter
  62. * old logs removed and tabs fixed
  63. Revision 1.6 2002/07/28 20:43:48 florian
  64. * several fixes for linux/powerpc
  65. * several fixes to MT
  66. }