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

Method AddTask

Libraries/unrar/threadpool.cpp:167–180  ·  view source on GitHub ↗

Add task to queue. We assume that it is always called from main thread, it allows to avoid any locks here. We process collected tasks only when WaitDone is called.

Source from the content-addressed store, hash-verified

165// it allows to avoid any locks here. We process collected tasks only
166// when WaitDone is called.
167void ThreadPool::AddTask(PTHREAD_PROC Proc,void *Data)
168{
169 if (ThreadsCreatedCount == 0)
170 CreateThreads();
171
172 // If queue is full, wait until it is empty.
173 if (ActiveThreads>=ASIZE(TaskQueue))
174 WaitDone();
175
176 TaskQueue[QueueTop].Proc = Proc;
177 TaskQueue[QueueTop].Param = Data;
178 QueueTop = (QueueTop + 1) % ASIZE(TaskQueue);
179 ActiveThreads++;
180}
181
182
183// Start queued tasks and wait until all threads are inactive.

Callers 4

ProcessRSMethod · 0.80
blake2sp_updateFunction · 0.80
RestoreMethod · 0.80
Unpack5MTMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected