1/* -*- C++ -*-
2 This file declares 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
9#ifndef WEAVERIMPLSTATE_H
10#define WEAVERIMPLSTATE_H
11
12#include "state.h"
13#include "weaver.h"
14
15namespace ThreadWeaver
16{
17class QueueSignals;
18
19/** @brief Base class for all WeaverImpl states. */
20class WeaverImplState : public State
21{
22public:
23 explicit WeaverImplState(QueueSignals *weaver);
24
25 const State *state() const override;
26
27 /** Shut down the queue. */
28 void shutDown() override;
29 /** Set the maximum number of threads this Weaver object may start. */
30 void setMaximumNumberOfThreads(int cap) override;
31 /** Get the maximum number of threads this Weaver may start. */
32 int maximumNumberOfThreads() const override;
33 /** Returns the current number of threads in the inventory. */
34 int currentNumberOfThreads() const override;
35 /** Enqueue a job. */
36 void enqueue(const QList<JobPointer> &jobs) override;
37 /** Dequeue a job. */
38 bool dequeue(const JobPointer &job) override;
39 /** Dequeue all jobs. */
40 void dequeue() override;
41 /** Finish all queued jobs. */
42 void finish() override;
43 /** Are no more jobs queued? */
44 bool isEmpty() const override;
45 /** Are all threads waiting? */
46 bool isIdle() const override;
47 /** How many jobs are currently queued? */
48 int queueLength() const override;
49 /** Request abort for all queued and currently executed jobs. */
50 void requestAbort() override;
51 /** Reschedule jobs to threads. */
52 void reschedule() override;
53 /** Wait (by suspending the calling thread) until a job becomes available. */
54 void waitForAvailableJob(Thread *th) override;
55
56protected:
57 /** Provide correct return type for WeaverImpl states. */
58 Weaver *weaver() override;
59 const Weaver *weaver() const override;
60};
61
62}
63
64#endif
65

source code of threadweaver/src/weaverimplstate.h