File indexing completed on 2024-04-21 04:01:28

0001 /* -*- C++ -*-
0002     This file is part of ThreadWeaver, a KDE framework.
0003 
0004     SPDX-FileCopyrightText: 2013 Mirko Boehm <mirko@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef THREADWEAVER_QUEUESIGNALS_H
0010 #define THREADWEAVER_QUEUESIGNALS_H
0011 
0012 #include "queueinterface.h"
0013 #include <QObject>
0014 
0015 namespace ThreadWeaver
0016 {
0017 namespace Private
0018 {
0019 class QueueSignals_Private;
0020 }
0021 
0022 /** @brief QueueSignals declares the Qt signals shared by the Queue and Weaver classes. */
0023 class THREADWEAVER_EXPORT QueueSignals : public QObject, public QueueInterface
0024 {
0025     Q_OBJECT
0026 public:
0027     explicit QueueSignals(QObject *parent = nullptr);
0028     explicit QueueSignals(ThreadWeaver::Private::QueueSignals_Private *d, QObject *parent = nullptr);
0029     ~QueueSignals() override;
0030 
0031 Q_SIGNALS:
0032     /** @brief Emitted when the Queue has completed all jobs currently queued.
0033      *
0034      * The Queue emits finished() when the job queue is empty, and the last job currently processed by a worker threads was
0035      * completed. Beware that if multiple jobs are enqueued repeatedly one by one, this signal might be emitted multiple times, because the
0036      * queued jobs where processed before new ones could be queued. To avoid this, queue all relevant jobs in a single operation,
0037      * using for example a QueueStream or a Collection.
0038      */
0039     void finished();
0040 
0041     /** @brief The Queue has been suspended.
0042      *
0043      * When the Queue is suspended, worker threads will not be assigned new jobs to process. Jobs waiting in the queue will not be
0044      * started until processing is resumed. When suspend() is called, the worker threads will continue to process the job currently
0045      * assigned to them. When the last thread finishes it's current assignment, suspended() is emitted.
0046      *
0047      * @see suspend()
0048      */
0049     void suspended();
0050 
0051     /** @brief Emitted when the processing state of the Queue has changed. */
0052     void stateChanged(ThreadWeaver::State *);
0053 
0054 protected:
0055     ThreadWeaver::Private::QueueSignals_Private *d();
0056     const ThreadWeaver::Private::QueueSignals_Private *d() const;
0057 
0058 private:
0059     ThreadWeaver::Private::QueueSignals_Private *m_d;
0060 };
0061 
0062 }
0063 
0064 #endif // THREADWEAVER_QUEUESIGNALS_H