| 298 | } |
| 299 | |
| 300 | void VideoCache::startWorkerThreads(int nrThreads) |
| 301 | { |
| 302 | for (int i = 0; i < nrThreads; i++) |
| 303 | { |
| 304 | loadingThread *newThread = new loadingThread(this); |
| 305 | cachingThreadList.append(newThread); |
| 306 | |
| 307 | // Caching should run in the background without interrupting normal operation. Start with lowest |
| 308 | // priority. |
| 309 | newThread->start(QThread::LowestPriority); |
| 310 | |
| 311 | // Connect the signals/slots to communicate with the cacheWorker. |
| 312 | connect(newThread->worker(), |
| 313 | &loadingWorker::loadingFinished, |
| 314 | this, |
| 315 | &VideoCache::threadCachingFinished); |
| 316 | |
| 317 | DEBUG_CACHING("VideoCache::startWorkerThreads Started thread %p", newThread); |
| 318 | |
| 319 | if (workersState == workersRunning) |
| 320 | // Push the next job to the worker. Otherwise it will not start working if caching is |
| 321 | // currently running. |
| 322 | pushNextJobToCachingThread(newThread); |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | void VideoCache::updateSettings() |
| 327 | { |