File indexing completed on 2024-04-21 04:01:27
0001 /* -*- C++ -*- 0002 This file is part of ThreadWeaver. 0003 0004 SPDX-FileCopyrightText: 2005-2013 Mirko Boehm <mirko@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef JOB_P_H 0010 #define JOB_P_H 0011 0012 #include "executewrapper_p.h" 0013 #include <QList> 0014 #include <QMutex> 0015 0016 #include <atomic> 0017 #include <functional> 0018 0019 namespace ThreadWeaver 0020 { 0021 namespace Private 0022 { 0023 class THREADWEAVER_EXPORT DefaultExecutor : public ThreadWeaver::Executor 0024 { 0025 public: 0026 void begin(const JobPointer &job, Thread *thread) override; 0027 void execute(const JobPointer &job, Thread *thread) override; 0028 void end(const JobPointer &job, Thread *thread) override; 0029 }; 0030 0031 extern DefaultExecutor defaultExecutor; 0032 0033 class DebugExecuteWrapper : public ThreadWeaver::ExecuteWrapper 0034 { 0035 public: 0036 void execute(const JobPointer &job, ThreadWeaver::Thread *th) override; 0037 }; 0038 0039 class Job_Private 0040 { 0041 public: 0042 Job_Private(); 0043 virtual ~Job_Private(); 0044 0045 /** Free the queue policies acquired before this job has been executed. */ 0046 virtual void freeQueuePolicyResources(JobPointer); 0047 0048 /* The list of QueuePolicies assigned to this Job. */ 0049 QList<QueuePolicy *> queuePolicies; 0050 0051 mutable QMutex mutex; 0052 /* @brief The status of the Job. */ 0053 QAtomicInt status; 0054 0055 std::atomic_bool shouldAbort; 0056 0057 /** The Executor that will execute this Job. */ 0058 QAtomicPointer<Executor> executor; 0059 0060 QList<std::function<void(const JobInterface &job)>> finishHandlers; 0061 void handleFinish(const JobPointer &job); 0062 0063 // FIXME What is the correct KDE frameworks no debug switch? 0064 #if !defined(NDEBUG) 0065 /** DebugExecuteWrapper for logging of Job execution. */ 0066 DebugExecuteWrapper debugExecuteWrapper; 0067 #endif 0068 }; 0069 0070 } 0071 0072 } 0073 0074 #endif // JOB_P_H