| 117 | } |
| 118 | |
| 119 | void* TIBMemPool::ThreadFunc(void* param) { |
| 120 | BindToSocket(0); |
| 121 | SetHighestThreadPriority(); |
| 122 | TIBMemPool* pThis = (TIBMemPool*)param; |
| 123 | pThis->HasStarted.Signal(); |
| 124 | |
| 125 | while (pThis->KeepRunning) { |
| 126 | TJobItem* work = nullptr; |
| 127 | if (!pThis->Requests.Dequeue(&work)) { |
| 128 | pThis->HasWork.Reset(); |
| 129 | if (!pThis->Requests.Dequeue(&work)) { |
| 130 | pThis->HasWork.Wait(); |
| 131 | } |
| 132 | } |
| 133 | if (work) { |
| 134 | //printf("mem copy got work\n"); |
| 135 | int sz = work->Data->GetSize(); |
| 136 | work->Block = pThis->Alloc(sz); |
| 137 | TBlockChainIterator bc(work->Data->GetChain()); |
| 138 | bc.Read(work->Block->GetData(), sz); |
| 139 | TIntrusivePtr<TCopyResultStorage> dst = work->ResultStorage; |
| 140 | work->ResultStorage = nullptr; |
| 141 | dst->Results.Enqueue(work); |
| 142 | //printf("mem copy completed\n"); |
| 143 | } |
| 144 | } |
| 145 | return nullptr; |
| 146 | } |
| 147 | |
| 148 | ////////////////////////////////////////////////////////////////////////// |
| 149 | static TMutex IBMemMutex; |
nothing calls this directly
no test coverage detected