MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / startTasks

Method startTasks

Engine/OutputSchedulerThread.cpp:911–983  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

909}
910
911void
912OutputSchedulerThread::startTasks(int startingFrame)
913{
914 int maxThreads = _imp->threadPool->maxThreadCount();
915 int activeThreads = _imp->getNActiveRenderThreads();
916
917 //This thread is from the thread pool so do not count it as it is probably done anyway
918 if (QThread::currentThread() != this) {
919 activeThreads -= 1;
920 }
921
922
923 int nFrames;
924#ifdef NATRON_SCHEDULER_SPAWN_THREADS_WITH_TIMER
925 //We check every now and then if we need to start new threads
926 {
927 int nbAvailableThreads = maxThreads - activeThreads;
928 if (nbAvailableThreads <= 0) {
929 return;
930 }
931 nFrames = 1;
932 }
933#else
934 //Start one more thread until we use all the thread pool.
935 //We leave some CPU available so that the multi-thread suite can take advantage of it
936 nFrames = MathUtils::clamp(maxThreads - activeThreads, 1, 1);
937#endif
938
939
940 RenderDirectionEnum direction;
941 int firstFrame, lastFrame, frameStep;
942 bool useStats;
943 std::vector<int> viewsToRender;
944 {
945 QMutexLocker l(&_imp->runArgsMutex);
946 direction = _imp->livingRunArgs.timelineDirection;
947 firstFrame = _imp->livingRunArgs.firstFrame;
948 lastFrame = _imp->livingRunArgs.lastFrame;
949 frameStep = _imp->livingRunArgs.frameStep;
950 useStats = _imp->livingRunArgs.enableRenderStats;
951 viewsToRender = _imp->livingRunArgs.viewsToRender;
952 }
953 PlaybackModeEnum pMode = _imp->engine->getPlaybackMode();
954 if (firstFrame == lastFrame) {
955 RenderThreadTask* task = createRunnable(startingFrame, useStats, viewsToRender);
956 _imp->appendRunnable(task);
957
958 QMutexLocker k(&_imp->framesToRenderMutex);
959 _imp->lastFramePushedIndex = startingFrame;
960 } else {
961 int frame = startingFrame;
962 RenderDirectionEnum newDirection = direction;
963 for (int i = 0; i < nFrames; ++i) {
964 RenderThreadTask* task = createRunnable(frame, useStats, viewsToRender);
965 _imp->appendRunnable(task);
966
967
968 {

Callers

nothing calls this directly

Calls 4

clampFunction · 0.85
appendRunnableMethod · 0.80
getPlaybackModeMethod · 0.45

Tested by

no test coverage detected