File indexing completed on 2024-04-28 15:34:51

0001 /* -*- C++ -*-
0002     Class to manipulate job execution in 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 EXECUTEWRAPPER_H
0010 #define EXECUTEWRAPPER_H
0011 
0012 #include <QAtomicPointer>
0013 
0014 #include "executor_p.h"
0015 #include "job.h"
0016 
0017 namespace ThreadWeaver
0018 {
0019 class Job;
0020 class Thread;
0021 
0022 // FIXME Pimpl, make part of the API, document
0023 // Find a way to avoid new/delete operation, this is rather performance sensitive area
0024 class ExecuteWrapper : public Executor
0025 {
0026 public:
0027     ExecuteWrapper();
0028     Executor *wrap(Executor *previous);
0029     Executor *unwrap(const JobPointer &job);
0030     void begin(const JobPointer &job, Thread *) override;
0031     void execute(const JobPointer &job, Thread *thread) override;
0032     void executeWrapped(const JobPointer &job, Thread *thread);
0033     void end(const JobPointer &job, Thread *) override;
0034 
0035 private:
0036     QAtomicPointer<Executor> wrapped;
0037 };
0038 
0039 }
0040 
0041 #endif // EXECUTEWRAPPER_H