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 JOB_P_H
10#define JOB_P_H
11
12#include "executewrapper_p.h"
13#include <QList>
14#include <QMutex>
15
16#include <atomic>
17#include <functional>
18
19namespace ThreadWeaver
20{
21namespace Private
22{
23class THREADWEAVER_EXPORT DefaultExecutor : public ThreadWeaver::Executor
24{
25public:
26 void begin(const JobPointer &job, Thread *thread) override;
27 void execute(const JobPointer &job, Thread *thread) override;
28 void end(const JobPointer &job, Thread *thread) override;
29};
30
31extern DefaultExecutor defaultExecutor;
32
33class DebugExecuteWrapper : public ThreadWeaver::ExecuteWrapper
34{
35public:
36 void execute(const JobPointer &job, ThreadWeaver::Thread *th) override;
37};
38
39class Job_Private
40{
41public:
42 Job_Private();
43 virtual ~Job_Private();
44
45 /** Free the queue policies acquired before this job has been executed. */
46 virtual void freeQueuePolicyResources(JobPointer);
47
48 /* The list of QueuePolicies assigned to this Job. */
49 QList<QueuePolicy *> queuePolicies;
50
51 mutable QMutex mutex;
52 /* @brief The status of the Job. */
53 QAtomicInt status;
54
55 std::atomic_bool shouldAbort;
56
57 /** The Executor that will execute this Job. */
58 QAtomicPointer<Executor> executor;
59
60 QList<std::function<void(const JobInterface &job)>> finishHandlers;
61 void handleFinish(const JobPointer &job);
62
63 // FIXME What is the correct KDE frameworks no debug switch?
64#if !defined(NDEBUG)
65 /** DebugExecuteWrapper for logging of Job execution. */
66 DebugExecuteWrapper debugExecuteWrapper;
67#endif
68};
69
70}
71
72}
73
74#endif // JOB_P_H
75

source code of threadweaver/src/job_p.h