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 | |
15 | namespace ThreadWeaver |
16 | { |
17 | namespace Private |
18 | { |
19 | class QueueSignals_Private; |
20 | } |
21 | |
22 | /*! |
23 | * \class ThreadWeaver::Private::QueueSignals |
24 | * |
25 | * \inmodule ThreadWeaver |
26 | * |
27 | * \brief QueueSignals declares the Qt signals shared by the Queue and Weaver classes. |
28 | */ |
29 | class THREADWEAVER_EXPORT QueueSignals : public QObject, public QueueInterface |
30 | { |
31 | Q_OBJECT |
32 | public: |
33 | /*! |
34 | */ |
35 | explicit QueueSignals(QObject *parent = nullptr); |
36 | /*! |
37 | */ |
38 | explicit QueueSignals(ThreadWeaver::Private::QueueSignals_Private *d, QObject *parent = nullptr); |
39 | ~QueueSignals() override; |
40 | |
41 | Q_SIGNALS: |
42 | /*! \brief Emitted when the Queue has completed all jobs currently queued. |
43 | * |
44 | * The Queue emits finished() when the job queue is empty, and the last job currently processed by a worker threads was |
45 | * completed. Beware that if multiple jobs are enqueued repeatedly one by one, this signal might be emitted multiple times, because the |
46 | * queued jobs where processed before new ones could be queued. To avoid this, queue all relevant jobs in a single operation, |
47 | * using for example a QueueStream or a Collection. |
48 | */ |
49 | void finished(); |
50 | |
51 | /*! \brief The Queue has been suspended. |
52 | * |
53 | * When the Queue is suspended, worker threads will not be assigned new jobs to process. Jobs waiting in the queue will not be |
54 | * started until processing is resumed. When suspend() is called, the worker threads will continue to process the job currently |
55 | * assigned to them. When the last thread finishes it's current assignment, suspended() is emitted. |
56 | * |
57 | * \sa suspend() |
58 | */ |
59 | void suspended(); |
60 | |
61 | /*! \brief Emitted when the processing state of the Queue has changed. */ |
62 | void stateChanged(ThreadWeaver::State *); |
63 | |
64 | protected: |
65 | /*! |
66 | */ |
67 | ThreadWeaver::Private::QueueSignals_Private *d(); |
68 | /*! |
69 | */ |
70 | const ThreadWeaver::Private::QueueSignals_Private *d() const; |
71 | |
72 | private: |
73 | ThreadWeaver::Private::QueueSignals_Private *m_d; |
74 | }; |
75 | |
76 | } |
77 | |
78 | #endif // THREADWEAVER_QUEUESIGNALS_H |
79 | |