Blender  V2.93
util_tbb.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2020 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __UTIL_TBB_H__
18 #define __UTIL_TBB_H__
19 
20 /* TBB includes <windows.h>, do it ourselves first so we are sure
21  * WIN32_LEAN_AND_MEAN and similar are defined beforehand. */
22 #include "util_windows.h"
23 
24 #include <tbb/enumerable_thread_specific.h>
25 #include <tbb/parallel_for.h>
26 #include <tbb/task_arena.h>
27 #include <tbb/task_group.h>
28 
29 #if TBB_INTERFACE_VERSION_MAJOR >= 10
30 # define WITH_TBB_GLOBAL_CONTROL
31 # include <tbb/global_control.h>
32 #endif
33 
35 
36 using tbb::blocked_range;
37 using tbb::enumerable_thread_specific;
38 using tbb::parallel_for;
39 
40 static inline void parallel_for_cancel()
41 {
42 #if TBB_INTERFACE_VERSION_MAJOR >= 12
43  tbb::task_group_context *ctx = tbb::task::current_context();
44  if (ctx) {
45  ctx->cancel_group_execution();
46  }
47 #else
48  tbb::task::self().cancel_group_execution();
49 #endif
50 }
51 
53 
54 #endif /* __UTIL_TBB_H__ */
PyObject * self
Definition: bpy_driver.c:185
#define CCL_NAMESPACE_END
void parallel_for(IndexRange range, int64_t grain_size, const Function &function)
Definition: BLI_task.hh:62
static void parallel_for_cancel()
Definition: util_tbb.h:40