OpenVDB 13.0.1
Loading...
Searching...
No Matches
Threading.h
Go to the documentation of this file.
1// Copyright Contributors to the OpenVDB Project
2// SPDX-License-Identifier: Apache-2.0
3//
4/// @file Threading.h
5
6#ifndef OPENVDB_THREAD_THREADING_HAS_BEEN_INCLUDED
7#define OPENVDB_THREAD_THREADING_HAS_BEEN_INCLUDED
8
9#include <openvdb/version.h>
10
11#ifndef __TBB_show_deprecation_message_task_H
12 #define __TBB_show_deprecation_message_task_H
13 #define OPENVDB_THREAD_THREADING_RESTORE_DEPRECATION_MESSAGE_TASK
14#endif
15
16
17#include <tbb/blocked_range.h>
18#include <tbb/task.h>
19/// @note tbb/task_arena.h is the ONLY include that persists from TBB 2020
20/// to TBB 2021 to TBB 2023 that itself includes the TBB specific version
21/// header files.
22/// In TBB 2020, the version header was called tbb/stddef.h. In 2021+, it's
23/// called tbb/version.h. We include tbb/task_arena.h here to indirectly
24/// access the version defines in a consistent way so that downstream
25/// software doesn't need to provide compile time defines.
26#include <tbb/task_arena.h>
27#include <tbb/task_group.h>
28
29namespace openvdb {
31namespace OPENVDB_VERSION_NAME {
32namespace thread {
33
34/// @note This UBSAN suppression may not be needed when we transition to TBB21
36{
37 // @note 12000 was the 2021.1-beta05 release. The 2021.1-beta08 release
38 // introduced current_context().
39#if TBB_INTERFACE_VERSION >= 12002
40 auto ctx = tbb::task::current_context();
41 return ctx ? ctx->cancel_group_execution() : false;
42#else
43 return tbb::task::self().cancel_group_execution();
44#endif
45}
46
47/// @note This UBSAN suppression may not be needed when we transition to TBB21
49{
50 // @note 12000 was the 2021.1-beta05 release. The 2021.1-beta08 release
51 // introduced current_context().
52#if TBB_INTERFACE_VERSION >= 12002
53 auto ctx = tbb::task::current_context();
54 return ctx ? ctx->is_group_execution_cancelled() : false;
55#else
56 return tbb::task::self().is_cancelled();
57#endif
58}
59
60} // namespace thread
61} // namespace OPENVDB_VERSION_NAME
62} // namespace openvdb
63
64#ifdef OPENVDB_THREAD_THREADING_RESTORE_DEPRECATION_MESSAGE_TASK
65 #undef __TBB_show_deprecation_message_task_H
66 #undef OPENVDB_THREAD_THREADING_RESTORE_DEPRECATION_MESSAGE_TASK
67#endif
68
69
70#endif // OPENVDB_THREAD_THREADING_HAS_BEEN_INCLUDED
#define OPENVDB_UBSAN_SUPPRESS(X)
Windows defines.
Definition Platform.h:64
Definition Threading.h:32
vptr bool cancelGroupExecution()
Definition Threading.h:35
vptr bool isGroupExecutionCancelled()
Definition Threading.h:48
Definition Exceptions.h:13
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:284