this->nMaxInputQueue = CE_MAX_INPUT_QUEUE_BUFFER;
| 62 | |
| 63 | // this->nMaxInputQueue = CE_MAX_INPUT_QUEUE_BUFFER; |
| 64 | BOOL InQueue::WriteInputQueue(const INPUT_RECORD *pr, BOOL bSetEvent /*= TRUE*/, DWORD nLength /*= 1*/) |
| 65 | { |
| 66 | // Передернуть буфер (записать в консоль то, что накопилось) |
| 67 | if (pr == NULL) |
| 68 | { |
| 69 | if (bSetEvent) |
| 70 | { |
| 71 | DEBUGSTRINPUTEVENT(L"SetEvent(this->hInputEvent)\n"); |
| 72 | if (this->hInputEvent) |
| 73 | SetEvent(this->hInputEvent); |
| 74 | } |
| 75 | return TRUE; |
| 76 | } |
| 77 | |
| 78 | const INPUT_RECORD *pSrc = pr; |
| 79 | |
| 80 | while (nLength--) |
| 81 | { |
| 82 | INPUT_RECORD* pNext = this->pInputQueueWrite; |
| 83 | |
| 84 | // Проверяем, есть ли свободное место в буфере |
| 85 | if (this->pInputQueueRead != this->pInputQueueEnd) |
| 86 | { |
| 87 | if (this->pInputQueueRead < this->pInputQueueEnd |
| 88 | && ((this->pInputQueueWrite+1) == this->pInputQueueRead)) |
| 89 | { |
| 90 | return FALSE; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | // OK |
| 95 | _ASSERTE(pSrc->EventType != 0); |
| 96 | *pNext = *(pSrc++); |
| 97 | this->pInputQueueWrite++; |
| 98 | InterlockedIncrement(&nUsedLen); |
| 99 | |
| 100 | if (this->pInputQueueWrite >= this->pInputQueueEnd) |
| 101 | this->pInputQueueWrite = this->pInputQueue; |
| 102 | |
| 103 | // Могут писать "пачку", тогда подождать ее окончания |
| 104 | if (bSetEvent && !nLength) |
| 105 | { |
| 106 | DEBUGSTRINPUTEVENT(L"SetEvent(this->hInputEvent)\n"); |
| 107 | if (this->hInputEvent) |
| 108 | SetEvent(this->hInputEvent); |
| 109 | } |
| 110 | |
| 111 | // Подвинуть указатель чтения, если до этого буфер был пуст |
| 112 | if (this->pInputQueueRead == this->pInputQueueEnd) |
| 113 | this->pInputQueueRead = pNext; |
| 114 | } |
| 115 | |
| 116 | return TRUE; |
| 117 | } |
| 118 | |
| 119 | BOOL InQueue::IsInputQueueEmpty() |
| 120 | { |
no outgoing calls