1/* -*- C++ -*-
2 Base class for job decorators 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 THREADWEAVER_IDDECORATOR_H
10#define THREADWEAVER_IDDECORATOR_H
11
12#include <QObject>
13
14#include "jobinterface.h"
15#include "threadweaver_export.h"
16
17namespace ThreadWeaver
18{
19class Collection;
20class Sequence;
21
22/*!
23 * \class ThreadWeaver::IdDecorator
24 * \inheaderfile ThreadWeaver/IdDecorator
25 * \inmodule ThreadWeaver
26 *
27 * \brief IdDecorator decorates a job without changing it's behaviour.
28 *
29 * It is supposed to be used as the base class for actual decorators that do change the behaviour of jobs.
30 */
31class THREADWEAVER_EXPORT IdDecorator : public JobInterface
32{
33public:
34 /*!
35 */
36 explicit IdDecorator(JobInterface *job, bool autoDelete = true);
37 ~IdDecorator() override;
38 /*! Retrieve the decorated job. */
39 const JobInterface *job() const;
40 /*! Retrieve the decorated job. */
41 JobInterface *job();
42 /*! Auto-delete the decoratee or not. */
43 void setAutoDelete(bool onOff);
44 /*! Will the decoratee be auto-deleted? */
45 bool autoDelete() const;
46 /*! Retrieve the decorated job as a Collection.
47 * If the decorated Job is not a Collection, 0 is returned. */
48 const Collection *collection() const;
49 /*! Retrieve the decorated job as a Collection.
50 * If the decorated Job is not a Collection, 0 is returned. */
51 Collection *collection();
52 /*! Retrieve the decorated job as a Sequence.
53 * If the decorated Job is not a Sequence, 0 is returned. */
54 const Sequence *sequence() const;
55 /*! Retrieve the decorated job as a Sequence.
56 * If the decorated Job is not a Sequence, 0 is returned. */
57 Sequence *sequence();
58
59 void execute(const JobPointer &job, Thread *) override;
60 void blockingExecute() override;
61 Executor *setExecutor(Executor *executor) override;
62 Executor *executor() const override;
63 int priority() const override;
64 void setStatus(Status) override;
65 Status status() const override;
66 bool success() const override;
67 void requestAbort() override;
68 void aboutToBeQueued(QueueAPI *api) override;
69 void aboutToBeQueued_locked(QueueAPI *api) override;
70 void aboutToBeDequeued(QueueAPI *api) override;
71 void aboutToBeDequeued_locked(QueueAPI *api) override;
72 bool isFinished() const override;
73 void assignQueuePolicy(QueuePolicy *) override;
74 void removeQueuePolicy(QueuePolicy *) override;
75 QList<QueuePolicy *> queuePolicies() const override;
76 QMutex *mutex() const override;
77
78protected:
79 void run(JobPointer self, Thread *thread) override;
80 void defaultBegin(const JobPointer &job, Thread *thread) override;
81 void defaultEnd(const JobPointer &job, Thread *thread) override;
82
83private:
84 class Private1;
85 Private1 *const d1;
86 class Private2;
87 Private2 *d2;
88};
89
90}
91
92#endif // THREADWEAVER_IDDECORATOR_H
93

source code of threadweaver/src/iddecorator.h