File indexing completed on 2024-04-28 04:01:23
0001 /* -*- C++ -*- 0002 This file implements the InConstructionState class. 0003 0004 SPDX-FileCopyrightText: 2005-2013 Mirko Boehm <mirko@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 0008 $Id: InConstructionState.cpp 30 2005-08-16 16:16:04Z mirko $ 0009 */ 0010 0011 #include "inconstructionstate.h" 0012 0013 #include "threadweaver.h" 0014 #include "weaver.h" 0015 0016 namespace ThreadWeaver 0017 { 0018 InConstructionState::InConstructionState(QueueSignals *weaver) 0019 : WeaverImplState(weaver) 0020 { 0021 } 0022 0023 void InConstructionState::suspend() 0024 { 0025 // this request is not handled in InConstruction state 0026 } 0027 0028 void InConstructionState::resume() 0029 { 0030 // this request is not handled in InConstruction state 0031 } 0032 0033 JobPointer InConstructionState::applyForWork(Thread *th, bool wasBusy) 0034 { 0035 Q_ASSERT(wasBusy == false); 0036 // As long as we are in the construction state, no jobs will be given 0037 // to the worker threads. The threads will be suspended. They will 0038 // return from the blocked state when jobs are queued. By then, we 0039 // should not be in InConstruction state anymore, and we hand the job 0040 // application over to the then active state. 0041 while (weaver()->state()->stateId() == InConstruction) { 0042 weaver()->waitForAvailableJob(th); 0043 } 0044 return weaver()->applyForWork(th, wasBusy); 0045 } 0046 0047 StateId InConstructionState::stateId() const 0048 { 0049 return InConstruction; 0050 } 0051 0052 }