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.

92 lines
2.7 KiB

  1. //---------------------------------------------------------------------
  2. // Copyright (C)1998 Microsoft Corporation, All Rights Reserved.
  3. //
  4. // iostatus.cpp
  5. //
  6. // Author:
  7. //
  8. // Edward Reus (edwardr) 02-28-98 Initial coding.
  9. //
  10. //---------------------------------------------------------------------
  11. #include "precomp.h"
  12. //---------------------------------------------------------------------
  13. // CIOSTATUS::CIOSTATUS()
  14. //
  15. //---------------------------------------------------------------------
  16. CIOSTATUS::CIOSTATUS()
  17. {
  18. m_dwMainThreadId = 0;
  19. m_hIoCompletionPort = INVALID_HANDLE_VALUE;
  20. m_lNumThreads = 0;
  21. m_lNumPendingThreads = 0;
  22. }
  23. //---------------------------------------------------------------------
  24. // CIOSTATUS::~CIOSTATUS()
  25. //
  26. //---------------------------------------------------------------------
  27. CIOSTATUS::~CIOSTATUS()
  28. {
  29. CloseHandle(m_hIoCompletionPort);
  30. }
  31. //------------------------------------------------------------------------
  32. // CIOSTATUS::operator new()
  33. //
  34. //------------------------------------------------------------------------
  35. void *CIOSTATUS::operator new( IN size_t Size )
  36. {
  37. void *pObj = AllocateMemory(Size);
  38. return pObj;
  39. }
  40. //------------------------------------------------------------------------
  41. // CIOSTATUS::operator delete()
  42. //
  43. //------------------------------------------------------------------------
  44. void CIOSTATUS::operator delete( IN void *pObj,
  45. IN size_t Size )
  46. {
  47. if (pObj)
  48. {
  49. DWORD dwStatus = FreeMemory(pObj);
  50. #ifdef DBG_MEM
  51. if (dwStatus)
  52. {
  53. DbgPrint("IrXfer: IrTran-P: CIOSTATUS::delete Failed: %d\n",
  54. dwStatus );
  55. }
  56. #endif
  57. }
  58. }
  59. //---------------------------------------------------------------------
  60. // CIOSTATUS::Initialize();
  61. //
  62. //---------------------------------------------------------------------
  63. DWORD CIOSTATUS::Initialize()
  64. {
  65. DWORD dwStatus = NO_ERROR;
  66. m_dwMainThreadId = GetCurrentThreadId();
  67. // Create an IO completion port to use in our asynchronous IO.
  68. m_hIoCompletionPort = CreateIoCompletionPort( INVALID_HANDLE_VALUE,
  69. 0,
  70. 0,
  71. 0 );
  72. if (!m_hIoCompletionPort)
  73. {
  74. dwStatus = GetLastError();
  75. #ifdef DBG_ERROR
  76. DbgPrint("CreateIoCompletionPort(): Failed: %d\n",dwStatus);
  77. #endif
  78. return dwStatus;
  79. }
  80. return dwStatus;
  81. }