ThreadWeaver

workinghardstate.cpp
1/* -*- C++ -*-
2 This file implements the WorkingHardState class.
3
4 SPDX-FileCopyrightText: 2005-2013 Mirko Boehm <mirko@kde.org>
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
18namespace ThreadWeaver
19{
20void WorkingHardState::activated()
21{
22 weaver()->reschedule();
23}
24
25WorkingHardState::WorkingHardState(Weaver *weaver)
26 : WeaverImplState(weaver)
27{
28}
29
30void WorkingHardState::suspend()
31{
32 weaver()->setState(Suspending);
33}
34
35void WorkingHardState::resume()
36{
37}
38
39JobPointer 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
53StateId WorkingHardState::stateId() const
54{
55 return WorkingHard;
56}
57
58}
Weaver * weaver() override
Provide correct return type for WeaverImpl states.
void reschedule() override
Reschedule the jobs in the queue.
Definition weaver.cpp:380
const QList< QKeySequence > & next()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:06 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.