void GfxImageLoaderEngine::run() { lock.lock(); while(true) { if(ops.isEmpty()) { wait.wait(&lock); } else { Op op = *ops.begin(); lock.unlock(); runOp(op); lock.lock(); } } }
int QDeclarativeTimeLinePrivate::advance(int t) { int pauseTime = -1; // XXX - surely there is a more efficient way? do { pauseTime = -1; // Minimal advance time int advanceTime = t; for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ++iter) { TimeLine &tl = *iter; Op &op = tl.ops.first(); int length = op.length - tl.consumedOpLength; if (length < advanceTime) { advanceTime = length; if (advanceTime == 0) break; } } t -= advanceTime; // Process until then. A zero length advance time will only process // sets. QList<QPair<int, Update> > updates; for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ) { QDeclarativeTimeLineValue *v = static_cast<QDeclarativeTimeLineValue *>(iter.key()); TimeLine &tl = *iter; Q_ASSERT(!tl.ops.isEmpty()); do { Op &op = tl.ops.first(); if (advanceTime == 0 && op.length != 0) continue; if (tl.consumedOpLength == 0 && op.type != Op::Pause && op.type != Op::Execute) tl.base = v->value(); if ((tl.consumedOpLength + advanceTime) == op.length) { if (op.type == Op::Execute) { updates << qMakePair(op.order, Update(op.event)); } else { bool changed = false; qreal val = value(op, op.length, tl.base, &changed); if (changed) updates << qMakePair(op.order, Update(v, val)); } tl.length -= qMin(advanceTime, tl.length); tl.consumedOpLength = 0; tl.ops.removeFirst(); } else { tl.consumedOpLength += advanceTime; bool changed = false; qreal val = value(op, tl.consumedOpLength, tl.base, &changed); if (changed) updates << qMakePair(op.order, Update(v, val)); tl.length -= qMin(advanceTime, tl.length); break; } } while(!tl.ops.isEmpty() && advanceTime == 0 && tl.ops.first().length == 0); if (tl.ops.isEmpty()) { iter = ops.erase(iter); v->_t = 0; } else { if (tl.ops.first().type == Op::Pause && pauseTime != 0) { int opPauseTime = tl.ops.first().length - tl.consumedOpLength; if (pauseTime == -1 || opPauseTime < pauseTime) pauseTime = opPauseTime; } else { pauseTime = 0; } ++iter; } } length -= qMin(length, advanceTime); syncPoint -= advanceTime; qSort(updates.begin(), updates.end()); updateQueue = &updates; for (int ii = 0; ii < updates.count(); ++ii) { const Update &v = updates.at(ii).second; if (v.g) { v.g->setValue(v.v); } else { v.e.d0(v.e.d1); } } updateQueue = 0; } while(t); return pauseTime; }