1 | /* -*- C++ -*- |
---|---|
2 | This file implements the StateImplementation 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: InConstructionState.cpp 30 2005-08-16 16:16:04Z mirko $ |
9 | */ |
10 | |
11 | #include "weaverimplstate.h" |
12 | |
13 | namespace ThreadWeaver |
14 | { |
15 | WeaverImplState::WeaverImplState(QueueSignals *weaver) |
16 | : State(weaver) |
17 | { |
18 | } |
19 | |
20 | const State *WeaverImplState::state() const |
21 | { |
22 | return this; |
23 | } |
24 | |
25 | void WeaverImplState::shutDown() |
26 | { |
27 | weaver()->shutDown_p(); |
28 | } |
29 | |
30 | Weaver *WeaverImplState::weaver() |
31 | { |
32 | Q_ASSERT(dynamic_cast<Weaver *>(State::weaver())); |
33 | return static_cast<Weaver *>(State::weaver()); |
34 | } |
35 | |
36 | const Weaver *WeaverImplState::weaver() const |
37 | { |
38 | Q_ASSERT(dynamic_cast<const Weaver *>(State::weaver())); |
39 | return static_cast<const Weaver *>(State::weaver()); |
40 | } |
41 | |
42 | void WeaverImplState::setMaximumNumberOfThreads(int cap) |
43 | { |
44 | weaver()->setMaximumNumberOfThreads_p(cap); |
45 | } |
46 | |
47 | int WeaverImplState::maximumNumberOfThreads() const |
48 | { |
49 | return weaver()->maximumNumberOfThreads_p(); |
50 | } |
51 | |
52 | int WeaverImplState::currentNumberOfThreads() const |
53 | { |
54 | return weaver()->currentNumberOfThreads_p(); |
55 | } |
56 | |
57 | void WeaverImplState::enqueue(const QList<JobPointer> &jobs) |
58 | { |
59 | weaver()->enqueue_p(jobs); |
60 | } |
61 | |
62 | bool WeaverImplState::dequeue(const JobPointer &job) |
63 | { |
64 | return weaver()->dequeue_p(job); |
65 | } |
66 | |
67 | void WeaverImplState::dequeue() |
68 | { |
69 | weaver()->dequeue_p(); |
70 | } |
71 | |
72 | void WeaverImplState::finish() |
73 | { |
74 | weaver()->finish_p(); |
75 | } |
76 | |
77 | bool WeaverImplState::isEmpty() const |
78 | { |
79 | return weaver()->isEmpty_p(); |
80 | } |
81 | |
82 | bool WeaverImplState::isIdle() const |
83 | { |
84 | return weaver()->isIdle_p(); |
85 | } |
86 | |
87 | int WeaverImplState::queueLength() const |
88 | { |
89 | return weaver()->queueLength_p(); |
90 | } |
91 | |
92 | void WeaverImplState::requestAbort() |
93 | { |
94 | return weaver()->requestAbort_p(); |
95 | } |
96 | |
97 | void WeaverImplState::reschedule() |
98 | { |
99 | // Not implemented, performed directly in Weaver::reschedule(). |
100 | } |
101 | |
102 | void WeaverImplState::waitForAvailableJob(Thread *th) |
103 | { |
104 | weaver()->blockThreadUntilJobsAreBeingAssigned(th); |
105 | } |
106 | |
107 | } |
108 |