1 | /* -*- C++ -*- |
---|---|
2 | This file implements the SuspendingState 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: SuspendingState.cpp 30 2005-08-16 16:16:04Z mirko $ |
9 | */ |
10 | |
11 | #include "suspendingstate.h" |
12 | |
13 | #include "state.h" |
14 | #include "threadweaver.h" |
15 | |
16 | namespace ThreadWeaver |
17 | { |
18 | SuspendingState::SuspendingState(Weaver *weaver) |
19 | : WeaverImplState(weaver) |
20 | { |
21 | } |
22 | |
23 | void SuspendingState::suspend() |
24 | { |
25 | // this request is not handled in Suspending state (we are already suspending...) |
26 | } |
27 | |
28 | void SuspendingState::resume() |
29 | { |
30 | weaver()->setState(WorkingHard); |
31 | } |
32 | |
33 | void SuspendingState::activated() |
34 | { |
35 | weaver()->reschedule(); |
36 | } |
37 | |
38 | JobPointer SuspendingState::applyForWork(Thread *th, bool wasBusy) |
39 | { |
40 | weaver()->takeFirstAvailableJobOrSuspendOrWait(th, threadWasBusy: wasBusy, suspendIfAllThreadsInactive: true, justReturning: true); |
41 | weaver()->waitForAvailableJob(th); |
42 | return weaver()->applyForWork(thread: th, wasBusy: false); |
43 | } |
44 | |
45 | StateId SuspendingState::stateId() const |
46 | { |
47 | return Suspending; |
48 | } |
49 | |
50 | } |
51 |