ThreadWeaver

workinghardstate.cpp
1 /* -*- C++ -*-
2  This file implements the WorkingHardState class.
3 
4  SPDX-FileCopyrightText: 2005-2013 Mirko Boehm <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 
8  $Id: WorkingHardState.cpp 30 2005-08-16 16:16:04Z mirko $
9 */
10 
11 #include "workinghardstate.h"
12 
13 #include "debuggingaids.h"
14 #include "job.h"
15 #include "thread.h"
16 #include "threadweaver.h"
17 
18 namespace ThreadWeaver
19 {
20 void WorkingHardState::activated()
21 {
22  weaver()->reschedule();
23 }
24 
25 WorkingHardState::WorkingHardState(Weaver *weaver)
26  : WeaverImplState(weaver)
27 {
28 }
29 
31 {
32  weaver()->setState(Suspending);
33 }
34 
35 void WorkingHardState::resume()
36 {
37 }
38 
39 JobPointer WorkingHardState::applyForWork(Thread *th, bool wasBusy)
40 {
41  // beware: this code is executed in the applying thread!
42  TWDEBUG(2, "WorkingHardState::applyForWork: thread %i applies for work in %s state.\n", th->id(), qPrintable(weaver()->state()->stateName()));
43  JobPointer next = weaver()->takeFirstAvailableJobOrSuspendOrWait(th, wasBusy, false, false);
44  if (next) {
45  return next;
46  } else {
47  // this is no infinite recursion: the state may have changed meanwhile, or jobs may have become available:
48  TWDEBUG(2, "WorkingHardState::applyForWork: repeating for thread %i in %s state.\n", th->id(), qPrintable(weaver()->state()->stateName()));
49  return weaver()->applyForWork(th, false);
50  }
51 }
52 
53 StateId WorkingHardState::stateId() const
54 {
55  return WorkingHard;
56 }
57 
58 }
void suspend()
QAction * next(const QObject *recvr, const char *slot, QObject *parent)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 21 2023 04:10:21 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.