ThreadWeaver

weaverimplstate.h
1 /* -*- C++ -*-
2  This file declares the StateIMplementation class.
3 
4  SPDX-FileCopyrightText: 2005-2013 Mirko Boehm <[email protected]>
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 
15 namespace ThreadWeaver
16 {
17 class QueueSignals;
18 
19 /** @brief Base class for all WeaverImpl states. */
20 class WeaverImplState : public State
21 {
22 public:
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 QVector<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 
56 protected:
57  /** Provide correct return type for WeaverImpl states. */
58  Weaver *weaver() override;
59  const Weaver *weaver() const override;
60 };
61 
62 }
63 
64 #endif
Base class for all WeaverImpl states.
void enqueue(const QVector< JobPointer > &jobs) override
Enqueue a job.
int currentNumberOfThreads() const override
Returns the current number of threads in the inventory.
bool isEmpty() const override
Are no more jobs queued?
void reschedule() override
Reschedule jobs to threads.
A Weaver manages worker threads.
Definition: weaver.h:34
void setMaximumNumberOfThreads(int cap) override
Set the maximum number of threads this Weaver object may start.
Weaver * weaver() override
Provide correct return type for WeaverImpl states.
void waitForAvailableJob(Thread *th) override
Wait (by suspending the calling thread) until a job becomes available.
int queueLength() const override
How many jobs are currently queued?
const State * state() const override
Return the state of the weaver object.
void finish() override
Finish all queued jobs.
QueueSignals declares the Qt signals shared by the Queue and Weaver classes.
Definition: queuesignals.h:23
int maximumNumberOfThreads() const override
Get the maximum number of threads this Weaver may start.
We use a State pattern to handle the system state in ThreadWeaver.
Definition: state.h:55
void dequeue() override
Dequeue all jobs.
bool isIdle() const override
Are all threads waiting?
Thread represents a worker thread in a Queue's inventory.
Definition: thread.h:27
void shutDown() override
Shut down the queue.
void requestAbort() override
Request abort for all queued and currently executed jobs.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Dec 9 2023 04:10:10 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.