ThreadWeaver

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