1/* -*- C++ -*-
2 This file is part of ThreadWeaver.
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 WEAVER_P_H
10#define WEAVER_P_H
11
12#include <QSemaphore>
13#include <QSharedPointer>
14#include <QWaitCondition>
15
16#include "jobpointer.h"
17#include "state.h"
18#include "thread.h"
19
20#include "queuesignals_p.h"
21
22namespace ThreadWeaver
23{
24namespace Private
25{
26class Weaver_Private : public QueueSignals_Private
27{
28public:
29 Weaver_Private();
30 ~Weaver_Private() override;
31
32 void dumpJobs();
33
34 bool canBeExecuted(JobPointer);
35 void deleteExpiredThreads();
36
37 /** The thread inventory. */
38 QList<Thread *> inventory;
39 /** Threads that have exited and can be deleted. */
40 QList<Thread *> expiredThreads;
41 /** The job queue. */
42 QList<JobPointer> assignments;
43 /** The number of jobs that are assigned to the worker threads, but not finished. */
44 int active;
45 /** The maximum number of worker threads. */
46 int inventoryMax;
47 /** Wait condition all idle or done threads wait for. */
48 QWaitCondition jobAvailable;
49 /** Wait for a job to finish. */
50 QWaitCondition jobFinished;
51 /** Mutex to serialize operations. */
52 QMutex *mutex;
53 /** Semaphore to ensure thread startup is in sequence. */
54 QSemaphore semaphore;
55 /** Before shutdown can proceed to close the running threads, it needs to ensure that all of them
56 * entered the run method. */
57 QAtomicInt createdThreads;
58 /** The state of the art.
59 * @see StateId
60 */
61 QAtomicPointer<State> state;
62 /** The state objects. */
63 QSharedPointer<State> states[NoOfStates];
64};
65
66}
67
68}
69
70#endif // WEAVER_P_H
71

source code of threadweaver/src/weaver_p.h