File indexing completed on 2024-04-21 04:01:27

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 EXECUTOR_H
0010 #define EXECUTOR_H
0011 
0012 #include "job.h"
0013 
0014 namespace ThreadWeaver
0015 {
0016 class Job;
0017 class Thread;
0018 
0019 // FIXME Pimpl, make part of the API, document
0020 // TODO can JobPointer references be used?
0021 class THREADWEAVER_EXPORT Executor
0022 {
0023 public:
0024     virtual ~Executor();
0025     virtual void begin(const JobPointer &, Thread *) = 0;
0026     void defaultBegin(const JobPointer &job, Thread *thread);
0027     virtual void execute(const JobPointer &, Thread *) = 0;
0028     virtual void end(const JobPointer &, Thread *) = 0;
0029     void defaultEnd(const JobPointer &job, Thread *thread);
0030 
0031     /// @return true when this executor should be owned by the job and deleted alongside it
0032     virtual bool ownedByJob() const
0033     {
0034         return false;
0035     }
0036 
0037     void run(const JobPointer &job, Thread *thread);
0038 };
0039 
0040 }
0041 
0042 #endif // EXECUTOR_H