OpenVDB 13.1.0
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/// @warning the below changes what includes are available from this header
17/// depending on whether version.h is available
18#if __has_include(<tbb/version.h>)
19 #include <tbb/version.h>
20#else
21 /// @note tbb/task_arena.h is the ONLY include that persists from TBB 2020
22 /// to TBB 2021 to TBB 2023 that itself includes the TBB specific version
23 /// header files.
24 /// In TBB 2020, the version header was called tbb/stddef.h. In 2021+, it's
25 /// called tbb/version.h. We include tbb/task_arena.h here to indirectly
26 /// access the version defines in a consistent way so that downstream
27 /// software doesn't need to provide compile time defines.
28 #include <tbb/task_arena.h>
29#endif
30
31#include <tbb/task_group.h>
32#include <tbb/blocked_range.h>
33#include <tbb/task.h>
34
35namespace openvdb {
37namespace OPENVDB_VERSION_NAME {
38namespace thread {
39
40/// @note This UBSAN suppression may not be needed when we transition to TBB21
42{
43 // @note 12000 was the 2021.1-beta05 release. The 2021.1-beta08 release
44 // introduced current_context().
45#if TBB_INTERFACE_VERSION >= 12002
46 auto ctx = tbb::task::current_context();
47 return ctx ? ctx->cancel_group_execution() : false;
48#else
49 return tbb::task::self().cancel_group_execution();
50#endif
51}
52
53/// @note This UBSAN suppression may not be needed when we transition to TBB21
55{
56 // @note 12000 was the 2021.1-beta05 release. The 2021.1-beta08 release
57 // introduced current_context().
58#if TBB_INTERFACE_VERSION >= 12002
59 auto ctx = tbb::task::current_context();
60 return ctx ? ctx->is_group_execution_cancelled() : false;
61#else
62 return tbb::task::self().is_cancelled();
63#endif
64}
65
66} // namespace thread
67} // namespace OPENVDB_VERSION_NAME
68} // namespace openvdb
69
70#ifdef OPENVDB_THREAD_THREADING_RESTORE_DEPRECATION_MESSAGE_TASK
71 #undef __TBB_show_deprecation_message_task_H
72 #undef OPENVDB_THREAD_THREADING_RESTORE_DEPRECATION_MESSAGE_TASK
73#endif
74
75
76#endif // OPENVDB_THREAD_THREADING_HAS_BEEN_INCLUDED
#define OPENVDB_UBSAN_SUPPRESS(X)
Windows defines.
Definition Platform.h:64
Definition Threading.h:38
vptr bool cancelGroupExecution()
Definition Threading.h:41
vptr bool isGroupExecutionCancelled()
Definition Threading.h:54
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:291