Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
1.9 KiB

  1. /*++
  2. Copyright (c) 1990-1994 Microsoft Corporation
  3. All rights reserved
  4. Module Name:
  5. ThreadM.h
  6. Abstract:
  7. Generic thread manager header.
  8. Author:
  9. Albert Ting (AlbertT) 13-Feb-1994
  10. Environment:
  11. User Mode -Win32
  12. Revision History:
  13. --*/
  14. //
  15. // Forward typedefs
  16. //
  17. typedef struct _TMSTATEVAR *PTMSTATEVAR;
  18. typedef enum _TMSTATUS {
  19. TMSTATUS_NULL = 0,
  20. TMSTATUS_DESTROY_REQ = 1,
  21. TMSTATUS_DESTROYED = 2,
  22. } TMSTATUS, *PTMSTATUS;
  23. /* ----------
  24. Valid TMSTATUS states:
  25. NULL -- Normal processing
  26. DESTROY_REQ -- No new jobs, jobs possibly running
  27. DESTROY_REQ, DESTROYED -- No new jobs, all jobs completed
  28. ----------- */
  29. typedef PVOID PJOB;
  30. //
  31. // pfnNextJob must synchronize access on its own
  32. //
  33. typedef PJOB (*PFNNEXTJOB)(PTMSTATEVAR pTMStateVar);
  34. typedef VOID (*PFNPROCESSJOB)(PTMSTATEVAR pTMStateVar, PJOB pJob);
  35. typedef VOID (*PFNNEWSTATE)(PTMSTATEVAR pTMStateVar);
  36. typedef VOID (*PFNCLOSESTATE)(PTMSTATEVAR pTMStateVar);
  37. typedef struct _TMSTATESTATIC {
  38. UINT uMaxThreads;
  39. UINT uIdleLife;
  40. PFNPROCESSJOB pfnProcessJob;
  41. PFNNEXTJOB pfnNextJob;
  42. PFNNEWSTATE pfnNewState;
  43. PFNCLOSESTATE pfnCloseState;
  44. PCRITICAL_SECTION pCritSec;
  45. } TMSTATESTATIC, *PTMSTATESTATIC;
  46. typedef struct _TMSTATEVAR {
  47. // --- Internal --
  48. PTMSTATESTATIC pTMStateStatic;
  49. TMSTATUS Status;
  50. UINT uActiveThreads;
  51. UINT uIdleThreads;
  52. HANDLE hTrigger;
  53. // --- Initialized by user --
  54. PVOID pUser; // User space
  55. } TMSTATEVAR;
  56. //
  57. // Prototypes
  58. //
  59. BOOL
  60. TMCreateStatic(
  61. PTMSTATESTATIC pTMStateStatic
  62. );
  63. VOID
  64. TMDestroyStatic(
  65. PTMSTATESTATIC pTMStateStatic
  66. );
  67. BOOL
  68. TMCreate(
  69. PTMSTATESTATIC pTMStateStatic,
  70. PTMSTATEVAR pTMStateVar
  71. );
  72. BOOL
  73. TMDestroy(
  74. PTMSTATEVAR pTMStateVar
  75. );
  76. BOOL
  77. TMAddJob(
  78. PTMSTATEVAR pTMStateVar
  79. );