JobPointer SuspendedState::applyForWork(Thread *th, bool wasBusy) { // suspend all threads in case they wake up: Q_ASSERT(wasBusy == 0); weaver()->waitForAvailableJob(th); return weaver()->applyForWork(th, wasBusy); }
Job* InConstructionState::applyForWork ( Thread *th, Job *previous) { // As long as we are in the construction state, no jobs will be given // to the worker threads. The threads will be suspended. They will // return from the blocked state when jobs are queued. By then, we // should not be in InConstruction state anymore, and we hand the job // application over to the then active state. while ( weaver()->state().stateId() == InConstruction ) { weaver()->waitForAvailableJob ( th); } return weaver()->applyForWork ( th, previous ); }
void SuspendedState::resume() { weaver()->setState(WorkingHard); }
void InConstructionState::waitForAvailableJob ( Thread * th) { weaver()->blockThreadUntilJobsAreBeingAssigned ( th ); }