Debian Codegraph @

src/python/PyImath/PyImathTask.h

raw
1 //
2 // SPDX-License-Identifier: BSD-3-Clause
3 // Copyright Contributors to the OpenEXR Project.
4 //
5
6 // clang-format off
7
8 #ifndef _PyImathTask_h_
9 #define _PyImathTask_h_
10
11 #include <cstddef>
12 #include "PyImathExport.h"
13
14 namespace PyImath {
15
16 struct Task
17 {
18 PYIMATH_EXPORT virtual ~Task() {}
19 PYIMATH_EXPORT virtual void execute(size_t start,size_t end) = 0;
20 PYIMATH_EXPORT virtual void execute(size_t start,size_t end, int tid) {execute(start,end);}
21 };
22
23 struct WorkerPool
24 {
25 PYIMATH_EXPORT virtual ~WorkerPool() {}
26 PYIMATH_EXPORT virtual size_t workers() const = 0;
27 PYIMATH_EXPORT virtual void dispatch(Task &task,size_t length) = 0;
28 PYIMATH_EXPORT virtual bool inWorkerThread() const = 0;
29
30 PYIMATH_EXPORT static WorkerPool *currentPool();
31 PYIMATH_EXPORT static void setCurrentPool(WorkerPool *pool);
32 };
33
34 PYIMATH_EXPORT void dispatchTask(Task &task,size_t length);
35 PYIMATH_EXPORT size_t workers();
36
37 }
38
39 #endif