ThreadWeaver

queuesignals.h
1/* -*- C++ -*-
2 This file is part of ThreadWeaver, a KDE framework.
3
4 SPDX-FileCopyrightText: 2013 Mirko Boehm <mirko@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef THREADWEAVER_QUEUESIGNALS_H
10#define THREADWEAVER_QUEUESIGNALS_H
11
12#include "queueinterface.h"
13#include <QObject>
14
15namespace ThreadWeaver
16{
17namespace Private
18{
19class QueueSignals_Private;
20}
21
22/** @brief QueueSignals declares the Qt signals shared by the Queue and Weaver classes. */
23class THREADWEAVER_EXPORT QueueSignals : public QObject, public QueueInterface
24{
26public:
27 explicit QueueSignals(QObject *parent = nullptr);
28 explicit QueueSignals(ThreadWeaver::Private::QueueSignals_Private *d, QObject *parent = nullptr);
29 ~QueueSignals() override;
30
32 /** @brief Emitted when the Queue has completed all jobs currently queued.
33 *
34 * The Queue emits finished() when the job queue is empty, and the last job currently processed by a worker threads was
35 * completed. Beware that if multiple jobs are enqueued repeatedly one by one, this signal might be emitted multiple times, because the
36 * queued jobs where processed before new ones could be queued. To avoid this, queue all relevant jobs in a single operation,
37 * using for example a QueueStream or a Collection.
38 */
39 void finished();
40
41 /** @brief The Queue has been suspended.
42 *
43 * When the Queue is suspended, worker threads will not be assigned new jobs to process. Jobs waiting in the queue will not be
44 * started until processing is resumed. When suspend() is called, the worker threads will continue to process the job currently
45 * assigned to them. When the last thread finishes it's current assignment, suspended() is emitted.
46 *
47 * @see suspend()
48 */
49 void suspended();
50
51 /** @brief Emitted when the processing state of the Queue has changed. */
53
54protected:
55 ThreadWeaver::Private::QueueSignals_Private *d();
56 const ThreadWeaver::Private::QueueSignals_Private *d() const;
57
58private:
59 ThreadWeaver::Private::QueueSignals_Private *m_d;
60};
61
62}
63
64#endif // THREADWEAVER_QUEUESIGNALS_H
WeaverInterface provides a common interface for weaver implementations.
QueueSignals(QObject *parent=nullptr)
Construct a QueueSignals object, passing the QObject parent.
void finished()
Emitted when the Queue has completed all jobs currently queued.
void suspended()
The Queue has been suspended.
void stateChanged(ThreadWeaver::State *)
Emitted when the processing state of the Queue has changed.
We use a State pattern to handle the system state in ThreadWeaver.
Definition state.h:56
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 31 2025 11:57:50 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.