ThreadWeaver 5.109.0
queueinterface.h
1/* -*- C++ -*-
2 This file declares the QueueInterface 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 QueueInterface_H
10#define QueueInterface_H
11
12#include <QObject>
13#include <QVector>
14
15#include "jobinterface.h"
16#include "jobpointer.h"
17#include "threadweaver_export.h"
18
19namespace ThreadWeaver
20{
21class Job;
22class State;
23class WeaverObserver;
24
44class THREADWEAVER_EXPORT QueueInterface
45{
46public:
47 virtual ~QueueInterface()
48 {
49 }
51 virtual const State *state() const = 0;
52
57 virtual void shutDown() = 0;
58
60 virtual void setMaximumNumberOfThreads(int cap) = 0;
61
63 virtual int maximumNumberOfThreads() const = 0;
64
66 virtual int currentNumberOfThreads() const = 0;
67
79 virtual void enqueue(const QVector<JobPointer> &jobs) = 0;
80
96 virtual bool dequeue(const JobPointer &job) = 0;
97
104 virtual void dequeue() = 0;
115 virtual void finish() = 0;
125 virtual void suspend() = 0;
129 virtual void resume() = 0;
132 virtual bool isEmpty() const = 0;
136 virtual bool isIdle() const = 0;
142 virtual int queueLength() const = 0;
143
149 virtual void requestAbort() = 0;
150
154 virtual void reschedule() = 0;
155};
156
157}
158
159#endif
WeaverInterface provides a common interface for weaver implementations.
Definition queueinterface.h:45
virtual void enqueue(const QVector< JobPointer > &jobs)=0
Queue a vector of jobs.
virtual bool isEmpty() const =0
Is the queue empty? The queue is empty if no more jobs are queued.
virtual void requestAbort()=0
Request aborts of the currently executed jobs.
virtual bool isIdle() const =0
Is the weaver idle? The weaver is idle if no jobs are queued and no jobs are processed by the threads...
virtual int currentNumberOfThreads() const =0
Returns the current number of threads in the inventory.
virtual void finish()=0
Finish all queued operations, then return.
virtual void dequeue()=0
Remove all queued jobs.
virtual bool dequeue(const JobPointer &job)=0
Remove a job from the queue.
virtual int maximumNumberOfThreads() const =0
Get the maximum number of threads this Weaver may start.
virtual int queueLength() const =0
Returns the number of pending jobs.
virtual void shutDown()=0
Shut down the queue.
virtual void setMaximumNumberOfThreads(int cap)=0
Set the maximum number of threads this Weaver object may start.
virtual const State * state() const =0
Return the state of the weaver object.
virtual void suspend()=0
Suspend job execution.
virtual void reschedule()=0
Reschedule the jobs in the queue.
virtual void resume()=0
Resume job queueing.
We use a State pattern to handle the system state in ThreadWeaver.
Definition state.h:56