deps/unrar/threadpool.cpp
// 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.
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.
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 .
void ThreadPool::AddTask(PTHREAD_PROC Proc,void *Data)
{
  if (ThreadsCreatedCount == 0)
    CreateThreads();
  if (ActiveThreads>=ASIZE(TaskQueue))
    WaitDone();
  TaskQueue[QueueTop].Proc = Proc;
  TaskQueue[QueueTop].Param = Data;
  QueueTop = (QueueTop + 1) % ASIZE(TaskQueue);
  ActiveThreads++;
}
void ThreadPool :: AddTask ( PTHREAD_PROC Proc , void * Data ) { if ( ThreadsCreatedCount == 0 ) CreateThreads ( ) ; if ( ActiveThreads >= ASIZE ( TaskQueue ) ) WaitDone ( ) ; TaskQueue [ QueueTop ] . Proc = Proc ; TaskQueue [ QueueTop ] . Param = Data ; QueueTop = ( QueueTop + 1 ) % ASIZE ( TaskQueue ) ; ActiveThreads ++ ; }
Add task to queue.
Add task to queue .
// If queue is full, wait until it is empty.