int main ( int argc, char** argv ) { const int NoOfThreads = 4 ; const int NoOfJobs = NoOfThreads * 4 ; // number of jobs for every thread const int Multiplier = 250; // [0..9]* Multiplier sleep time for each job ThreadWeaver::setDebugLevel ( true, 4); QCoreApplication app ( argc, argv ); ThreadWeaver::Weaver weaver; weaver.setMaximumNumberOfThreads( NoOfThreads ); DummyJob *dummies[ NoOfJobs]; // ----- create a number of dummy jobs: for ( int count = 0; count < NoOfJobs; ++count ) { dummies[count] = new DummyJob (0, Multiplier * (count % 10) ); } // ----- enqueue the jobs: for ( int count = 0; count < NoOfJobs; ++count ) { weaver.enqueue( dummies[count] ); } weaver.finish(); for ( int count = 0; count < NoOfJobs; ++count ) { delete dummies[count]; } qDebug() << "main() exits here, the Weaver is destructed when it goes out" << " of scope " << endl << "... let's see if that works:" << endl; return 0; }
void JobTests::DequeSuspendedSequence() { ThreadWeaver::Weaver weaver; weaver.suspend(); weaver.enqueue(new ThreadWeaver::JobSequence(this) ); weaver.dequeue(); // don't crash }
int main ( int argc, char** argv ) { QApplication app ( argc, argv ); ThreadWeaver::setDebugLevel ( true, 1 ); ThreadWeaver::Weaver weaver; weaver.setMaximumNumberOfThreads (8); SMIV smiv ( & weaver ); smiv.show(); return app.exec(); }
void JobTests::WeaverLazyThreadCreationTest() { ThreadWeaver::Weaver weaver; QString sequence; QCOMPARE (weaver.currentNumberOfThreads(), 0); AppendCharacterJob a( QChar('a'), &sequence, this); weaver.enqueue( & a); weaver.finish(); QVERIFY(a.isFinished()); QCOMPARE (weaver.currentNumberOfThreads(), 1); }