-LayoutThread::LayoutThread() : QThread() {
- mutex.lock();
- abort = false;
- mutex.unlock();
-
-}
-
-LayoutThread::~LayoutThread() {
- mutex.lock();
- abort = true;
- mutex.unlock();
- condition.wakeOne();
- wait();
-}
-
-void LayoutThread::processTask(LayoutTask task) {
- if(!isRunning()) start();
- Q_ASSERT(isRunning());
- mutex.lock();
- queue.append(task);
- condition.wakeOne();
- mutex.unlock();
-}
-
-void LayoutThread::run() {
- forever {
- mutex.lock();
- if(!queue.count()) {
- condition.wait(&mutex);
- }
- if(abort) {
- mutex.unlock(); return;
- }
- Q_ASSERT(queue.count()); //qDebug() << "process";
- LayoutTask task = queue.takeFirst();
- mutex.unlock();
- /*
- foreach(Message msg, task.messages) {
- //qDebug() << msg.text;
- ChatLine *line = new ChatLine(msg, task.net, task.buf);
- task.lines.append(line);
- }
- emit taskProcessed(task);
- */
- //msleep(500);
- }
-}