Source code of Windows XP (NT5)
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.

128 lines
2.8 KiB

  1. /****************************************************************************
  2. *
  3. * disk32.h
  4. *
  5. * routines to do async disk writes in Win32 Chicago
  6. *
  7. ***************************************************************************/
  8. #if !defined DISK32_H
  9. #define DISK32_H
  10. #ifdef __cplusplus
  11. extern "C" { // Assume C declarations for C++
  12. #endif // __cplusplus
  13. // include this struct as a field in any code that is to be enqueued.
  14. //
  15. typedef struct _qelm * PQELM;
  16. typedef struct _qelm {
  17. PQELM pNext;
  18. PQELM pPrev;
  19. } QELM;
  20. // use this for the head/tail of a queue.
  21. //
  22. typedef struct _qhead * PQHEAD;
  23. typedef struct _qhead {
  24. HANDLE hEvtElms; // optional Semaphore that has element count
  25. CRITICAL_SECTION csList; // list synchronization lock
  26. QELM qe; // head/tail pointers
  27. } QHEAD;
  28. // Initalize the queue.
  29. //
  30. BOOL WINAPI QueueInitialize (
  31. PQHEAD pHead
  32. );
  33. // de-Initalize the queue
  34. //
  35. BOOL WINAPI QueueDelete (
  36. PQHEAD pHead
  37. );
  38. // insert an element in the queue. If a thread is waiting on the queue
  39. // it will be awakened.
  40. //
  41. VOID WINAPI QueueInsert (
  42. PQHEAD pHead,
  43. PQELM pqe
  44. );
  45. // remove an element from the queue. if the queue is empty.
  46. // wait for an element to be inserted. A timeout of 0 can be
  47. // used to POLL the queue.
  48. //
  49. PQELM WINAPI QueueRemove (
  50. PQHEAD pHead,
  51. DWORD dwTimeout
  52. );
  53. #ifdef DEBUG
  54. void WINAPI QueueDump (
  55. PQHEAD pHead
  56. );
  57. #else
  58. #define QueueDump(a)
  59. #endif
  60. typedef struct _qiobuf * PQIOBUF;
  61. typedef struct _qiobuf {
  62. QELM qe; // queue pointers, used by queue.c MUST be first field!!
  63. LPVOID lpv; // pointer to data
  64. DWORD cb; // size of data
  65. DWORD dwOffset; // file seek offset
  66. DWORD dwError; // success/fail of write operation
  67. DWORD cbDone; // actual bytes written/read
  68. BYTE bWrite; // read/write flag
  69. BYTE bPending; // TRUE when io has been removed from done queue
  70. BYTE bSpare[2]; // spare flags
  71. } QIOBUF;
  72. typedef struct _qio * LPQIO;
  73. typedef struct _qio {
  74. QHEAD que; // head for buffers queued to be written
  75. QHEAD queDone; // pointer to head of queue for write completion
  76. HANDLE hFile;
  77. HANDLE hThread;
  78. DWORD tid;
  79. UINT uState;
  80. UINT nIOCount;
  81. int nPrio;
  82. } QIO;
  83. BOOL WINAPI QioInitialize (
  84. LPQIO lpqio,
  85. HANDLE hFile,
  86. int nPrio
  87. );
  88. // add a buffer to the async io queue
  89. //
  90. BOOL WINAPI QioAdd (
  91. LPQIO lpqio,
  92. PQIOBUF pqBuf
  93. );
  94. BOOL WINAPI QioWait (
  95. LPQIO lpqio,
  96. PQIOBUF pqBufWait,
  97. BOOL bWait
  98. );
  99. BOOL WINAPI QioCommit (
  100. LPQIO lpqio
  101. );
  102. // Shutdown Qio thread
  103. //
  104. BOOL WINAPI QioShutdown (
  105. LPQIO lpqio
  106. );
  107. #ifdef __cplusplus
  108. } // Assume C declarations for C++
  109. #endif // __cplusplus
  110. #endif // DISK32_H