MCPcopy Create free account
hub / github.com/TeXworks/texworks / run

Method run

modules/QtPDF/src/PDFPageProcessingThread.cpp:95–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95void PDFPageProcessingThread::run()
96{
97 _mutex.lock();
98 _idle = false;
99 while (!_quit) {
100 // mutex must be locked at start of loop
101 if (!_workStack.empty()) {
102 PageProcessingRequest * workItem = _workStack.pop();
103 _mutex.unlock();
104
105#ifdef DEBUG
106 qDebug() << "processing work item" << *workItem << "; remaining items:" << _workStack.size();
107 QElapsedTimer timer;
108 timer.start();
109#endif
110 workItem->execute();
111#ifdef DEBUG
112 QString jobDesc;
113 switch (workItem->type()) {
114 case PageProcessingRequest::LoadLinks:
115 jobDesc = QString::fromUtf8("loading links");
116 break;
117 case PageProcessingRequest::PageRendering:
118 jobDesc = QString::fromUtf8("rendering page");
119 break;
120 }
121 qDebug() << "finished " << jobDesc << "for page" << workItem->page->pageNum() << ". Time elapsed: " << timer.elapsed() << " ms.";
122#endif
123
124 // Delete the work item as it has fulfilled its purpose
125 // Note that we can't delete it here or we might risk that some emitted
126 // signals are invalidated; to ensure they reach their destination, we
127 // need to call deleteLater().
128 // Note: workItem *must* live in the main (GUI) thread for this!
129 Q_ASSERT(workItem->thread() == QCoreApplication::instance()->thread());
130 workItem->deleteLater();
131
132 _mutex.lock();
133 }
134 else {
135#ifdef DEBUG
136 qDebug() << "going to sleep";
137#endif
138 _idle = true;
139 _idleCondition.wakeAll();
140 _waitCondition.wait(&_mutex);
141 _idle = false;
142#ifdef DEBUG
143 qDebug() << "waking up";
144#endif
145 }
146 }
147 _mutex.unlock();
148}
149
150void PDFPageProcessingThread::clearWorkStack()
151{

Callers

nothing calls this directly

Calls 5

startMethod · 0.80
unlockMethod · 0.45
executeMethod · 0.45
typeMethod · 0.45
pageNumMethod · 0.45

Tested by

no test coverage detected