MCPcopy Create free account
hub / github.com/IENT/YUView / threadCachingFinished

Method threadCachingFinished

YUViewLib/src/video/VideoCache.cpp:1019–1215  ·  view source on GitHub ↗

One of the workers is done with it's caching operation. Give it a new task if there is one and we are not breaking the caching process.

Source from the content-addressed store, hash-verified

1017// One of the workers is done with it's caching operation. Give it a new task if there is one and we
1018// are not breaking the caching process.
1019void VideoCache::threadCachingFinished()
1020{
1021 // Get the thread that caused this call
1022 QObject * sender = QObject::sender();
1023 loadingWorker *worker = dynamic_cast<loadingWorker *>(sender);
1024 Q_ASSERT_X(worker->isWorking(), Q_FUNC_INFO, "The worker that just finished was not working?");
1025 worker->setWorking(false);
1026 DEBUG_CACHING_DETAIL(
1027 "VideoCache::threadCachingFinished - state %d - worker %p", workersState, worker);
1028
1029 // Check if all threads have stopped.
1030 bool jobsRunning = false;
1031 for (loadingThread *t : cachingThreadList)
1032 {
1033 DEBUG_CACHING_DETAIL("VideoCache::threadCachingFinished WorkerList - worker %p - working %d",
1034 t,
1035 t->worker()->isWorking());
1036 if (t->worker()->isWorking())
1037 // A job is still running. Wait.
1038 jobsRunning = true;
1039 }
1040
1041 if (testMode)
1042 {
1043 if (workersState == workersIntReqRestart)
1044 {
1045 // The test has not started yet. We are waiting for the normal caching to finish first.
1046 if (!jobsRunning)
1047 {
1048 DEBUG_CACHING("VideoCache::threadCachingFinished Start test now");
1049 testDuration.start();
1050 startCaching();
1051 }
1052 }
1053 else if (testLoopCount < 0 || workersState == workersIntReqStop)
1054 {
1055 // The test is over or was canceled.
1056 // We are not going to start any new threads. Wait for the remaining threads to finish.
1057 if (jobsRunning)
1058 DEBUG_CACHING("VideoCache::threadCachingFinished Test over - Waiting for jobs to finish");
1059 else
1060 {
1061 // Report the results of the test
1062 DEBUG_CACHING("VideoCache::threadCachingFinished Test over - All jobs finished");
1063 testFinished();
1064 // Restart normal caching
1065 updateCacheQueue();
1066 startCaching();
1067 }
1068 }
1069 else if (workersState == workersRunning)
1070 {
1071 // The caching performance test is running. Just push another test job.
1072 DEBUG_CACHING_DETAIL("VideoCache::threadCachingFinished Test mode - start next job");
1073 for (loadingThread *t : cachingThreadList)
1074 if (t->worker() == worker)
1075 jobsRunning |= pushNextJobToCachingThread(t);
1076 }

Callers

nothing calls this directly

Calls 8

isWorkingMethod · 0.80
setWorkingMethod · 0.80
workerMethod · 0.80
getCacheItemMethod · 0.80
itemCachingFinishedMethod · 0.80
dataMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected