ThreadWeaver

jobinterface.h
1/* -*- C++ -*-
2 Interface for jobs in 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 JOBINTERFACE_H
10#define JOBINTERFACE_H
11
12#include <QSharedPointer>
13
14#include "jobpointer.h"
15#include "threadweaver_export.h"
16
17class QMutex;
18
19namespace ThreadWeaver
20{
21class Thread;
22class Executor;
23class QueueAPI;
24class QueuePolicy;
25
26class JobInterface;
27typedef QSharedPointer<JobInterface> JobPointer;
28
29class THREADWEAVER_EXPORT JobInterface
30{
31public:
32 enum Status {
33 Status_NoStatus = 0,
34 Status_New,
35 Status_Queued,
36 Status_Running,
37 Status_Success,
38 Status_Failed,
39 Status_Aborted,
40 Status_NumberOfStatuses,
41 };
42
43 virtual ~JobInterface()
44 {
45 }
46 virtual void execute(const JobPointer &job, Thread *) = 0;
47 virtual void blockingExecute() = 0;
48 virtual Executor *setExecutor(Executor *executor) = 0;
49 virtual Executor *executor() const = 0;
50 virtual int priority() const = 0;
51 virtual Status status() const = 0;
52 virtual void setStatus(Status) = 0;
53 virtual bool success() const = 0;
54 virtual void requestAbort() = 0;
55 virtual void aboutToBeQueued(QueueAPI *api) = 0;
56 virtual void aboutToBeQueued_locked(QueueAPI *api) = 0;
57 virtual void aboutToBeDequeued(QueueAPI *api) = 0;
58 virtual void aboutToBeDequeued_locked(QueueAPI *api) = 0;
59 virtual bool isFinished() const = 0;
60 virtual void assignQueuePolicy(QueuePolicy *) = 0;
61 virtual void removeQueuePolicy(QueuePolicy *) = 0;
62 virtual QList<QueuePolicy *> queuePolicies() const = 0;
63 virtual void run(JobPointer self, Thread *thread) = 0;
64 friend class Executor;
65 virtual void defaultBegin(const JobPointer &job, Thread *thread) = 0;
66 virtual void defaultEnd(const JobPointer &job, Thread *thread) = 0;
67 virtual QMutex *mutex() const = 0;
68};
69
70}
71
72Q_DECLARE_METATYPE(ThreadWeaver::JobPointer)
73
74#endif // JOBINTERFACE_H
Q_SCRIPTABLE CaptureState status()
QFuture< T > run(Function function,...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 11:58:32 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.