GCC Code Coverage Report


Directory: ./
File: openvdb/openvdb/thread/Threading.h
Date: 2022-07-25 17:40:05
Exec Total Coverage
Lines: 3 3 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-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 /// @note tbb/blocked_range.h is the ONLY include that persists from TBB 2020
18 /// to TBB 2021 that itself includes the TBB specific version header files.
19 /// In TBB 2020, the version header was called tbb/stddef.h. In 2021, it's
20 /// called tbb/version.h. We include tbb/blocked_range.h here to indirectly
21 /// access the version defines in a consistent way so that downstream
22 /// software doesn't need to provide compile time defines.
23 #include <tbb/blocked_range.h>
24 #include <tbb/task.h>
25 #include <tbb/task_group.h>
26
27 namespace openvdb {
28 OPENVDB_USE_VERSION_NAMESPACE
29 namespace OPENVDB_VERSION_NAME {
30 namespace thread {
31
32 1107 inline bool cancelGroupExecution()
33 {
34 // @note 12000 was the 2021.1-beta05 release. The 2021.1-beta08 release
35 // introduced current_context().
36 #if TBB_INTERFACE_VERSION >= 12002
37 auto ctx = tbb::task::current_context();
38 return ctx ? ctx->cancel_group_execution() : false;
39 #else
40 1107 return tbb::task::self().cancel_group_execution();
41 #endif
42 }
43
44 inline bool isGroupExecutionCancelled()
45 {
46 // @note 12000 was the 2021.1-beta05 release. The 2021.1-beta08 release
47 // introduced current_context().
48 #if TBB_INTERFACE_VERSION >= 12002
49 auto ctx = tbb::task::current_context();
50 return ctx ? ctx->is_group_execution_cancelled() : false;
51 #else
52 110589 return tbb::task::self().is_cancelled();
53 #endif
54 }
55
56 } // namespace thread
57 } // namespace OPENVDB_VERSION_NAME
58 } // namespace openvdb
59
60 #ifdef OPENVDB_THREAD_THREADING_RESTORE_DEPRECATION_MESSAGE_TASK
61 #undef __TBB_show_deprecation_message_task_H
62 #undef OPENVDB_THREAD_THREADING_RESTORE_DEPRECATION_MESSAGE_TASK
63 #endif
64
65
66 #endif // OPENVDB_THREAD_THREADING_HAS_BEEN_INCLUDED
67