| 136 | |
| 137 | |
| 138 | bool ThreadPool::GetQueuedTask(QueueEntry *Task) |
| 139 | { |
| 140 | #ifdef _WIN_ALL |
| 141 | CWaitForSingleObject(QueuedTasksCnt); |
| 142 | #elif defined(_UNIX) |
| 143 | pthread_mutex_lock(&QueuedTasksCntMutex); |
| 144 | while (QueuedTasksCnt==0) |
| 145 | cpthread_cond_wait(&QueuedTasksCntCond,&QueuedTasksCntMutex); |
| 146 | QueuedTasksCnt--; |
| 147 | pthread_mutex_unlock(&QueuedTasksCntMutex); |
| 148 | #endif |
| 149 | |
| 150 | if (Closing) |
| 151 | return false; |
| 152 | |
| 153 | CriticalSectionStart(&CritSection); |
| 154 | |
| 155 | *Task = TaskQueue[QueueBottom]; |
| 156 | QueueBottom = (QueueBottom + 1) % ASIZE(TaskQueue); |
| 157 | |
| 158 | CriticalSectionEnd(&CritSection); |
| 159 | |
| 160 | return true; |
| 161 | } |
| 162 | |
| 163 | |
| 164 | // Add task to queue. We assume that it is always called from main thread, |
nothing calls this directly
no test coverage detected