| 804 | } |
| 805 | |
| 806 | int |
| 807 | OutputSchedulerThread::pickFrameToRender(RenderThreadTask* thread, |
| 808 | bool* enableRenderStats, |
| 809 | std::vector<ViewIdx>* viewsToRender) |
| 810 | { |
| 811 | ///Flag the thread as inactive |
| 812 | { |
| 813 | QMutexLocker l(&_imp->renderThreadsMutex); |
| 814 | RenderThreads::iterator found = _imp->getRunnableIterator(thread); |
| 815 | assert( found != _imp->renderThreads.end() ); |
| 816 | found->active = false; |
| 817 | |
| 818 | ///Wake up the scheduler if it is waiting for all threads do be inactive |
| 819 | _imp->allRenderThreadsInactiveCond.wakeOne(); |
| 820 | } |
| 821 | |
| 822 | |
| 823 | bool gotFrame = false; |
| 824 | int frame = -1; |
| 825 | { |
| 826 | QMutexLocker l(&_imp->framesToRenderMutex); |
| 827 | while ( _imp->framesToRender.empty() && !thread->mustQuit() ) { |
| 828 | ///Notify that we're no longer doing work |
| 829 | thread->notifyIsRunning(false); |
| 830 | |
| 831 | _imp->framesToRenderNotEmptyCond.wait(l.mutex()); |
| 832 | } |
| 833 | |
| 834 | if ( !_imp->framesToRender.empty() ) { |
| 835 | ///Notify that we're running for good, will do nothing if flagged already running |
| 836 | thread->notifyIsRunning(true); |
| 837 | |
| 838 | frame = _imp->framesToRender.front(); |
| 839 | |
| 840 | _imp->framesToRender.pop_front(); |
| 841 | |
| 842 | gotFrame = true; |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | // thread is quitting, make sure we notified the application it is no longer running |
| 847 | if (!gotFrame) { |
| 848 | thread->notifyIsRunning(false); |
| 849 | |
| 850 | *enableRenderStats = false; |
| 851 | |
| 852 | return -1; |
| 853 | } else { |
| 854 | ///Flag the thread as active |
| 855 | { |
| 856 | QMutexLocker l(&_imp->renderThreadsMutex); |
| 857 | RenderThreads::iterator found = _imp->getRunnableIterator(thread); |
| 858 | assert( found != _imp->renderThreads.end() ); |
| 859 | found->active = true; |
| 860 | } |
| 861 | |
| 862 | OutputSchedulerThreadStartArgsPtr args = _imp->runArgs.lock(); |
| 863 | *enableRenderStats = args->enableRenderStats; |
no test coverage detected