MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / GetQueuedTask

Method GetQueuedTask

Libraries/unrar/threadpool.cpp:138–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136
137
138bool 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,

Callers

nothing calls this directly

Calls 4

CWaitForSingleObjectFunction · 0.85
cpthread_cond_waitFunction · 0.85
CriticalSectionStartFunction · 0.85
CriticalSectionEndFunction · 0.85

Tested by

no test coverage detected