ThreadWeaver

weaverimplstate.h
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:
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
QueueSignals declares the Qt signals shared by the Queue and Weaver classes.
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
Base class for all WeaverImpl states.
void finish() override
Finish all queued jobs.
int queueLength() const override
How many jobs are currently queued?
void reschedule() override
Reschedule jobs to threads.
void dequeue() override
Dequeue all jobs.
int currentNumberOfThreads() const override
Returns the current number of threads in the inventory.
Weaver * weaver() override
Provide correct return type for WeaverImpl states.
void enqueue(const QList< JobPointer > &jobs) override
Enqueue a job.
void waitForAvailableJob(Thread *th) override
Wait (by suspending the calling thread) until a job becomes available.
const State * state() const override
Return the state of the weaver object.
bool isIdle() const override
Are all threads waiting?
void shutDown() override
Shut down the queue.
void requestAbort() override
Request abort for all queued and currently executed jobs.
void setMaximumNumberOfThreads(int cap) override
Set the maximum number of threads this Weaver object may start.
int maximumNumberOfThreads() const override
Get the maximum number of threads this Weaver may start.
bool isEmpty() const override
Are no more jobs queued?
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 Mon Nov 18 2024 12:09:38 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.