summaryrefslogtreecommitdiffstats
path: root/thirdparty/embree/common/algorithms/parallel_for.h
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/embree/common/algorithms/parallel_for.h')
-rw-r--r--thirdparty/embree/common/algorithms/parallel_for.h70
1 files changed, 23 insertions, 47 deletions
diff --git a/thirdparty/embree/common/algorithms/parallel_for.h b/thirdparty/embree/common/algorithms/parallel_for.h
index 6d411e4852..fd5213e70a 100644
--- a/thirdparty/embree/common/algorithms/parallel_for.h
+++ b/thirdparty/embree/common/algorithms/parallel_for.h
@@ -5,7 +5,7 @@
#include "../tasking/taskscheduler.h"
#include "../sys/array.h"
-#include "../math/math.h"
+#include "../math/emath.h"
#include "../math/range.h"
namespace embree
@@ -14,17 +14,17 @@ namespace embree
template<typename Index, typename Func>
__forceinline void parallel_for( const Index N, const Func& func)
{
-#if defined(TASKING_INTERNAL)
+#if defined(TASKING_INTERNAL) && !defined(TASKING_TBB)
if (N) {
+ TaskScheduler::TaskGroupContext context;
TaskScheduler::spawn(Index(0),N,Index(1),[&] (const range<Index>& r) {
assert(r.size() == 1);
func(r.begin());
- });
- if (!TaskScheduler::wait())
- // -- GODOT start --
- // throw std::runtime_error("task cancelled");
- abort();
- // -- GODOT end --
+ },&context);
+ TaskScheduler::wait();
+ if (context.cancellingException != nullptr) {
+ std::rethrow_exception(context.cancellingException);
+ }
}
#elif defined(TASKING_TBB)
#if TBB_INTERFACE_VERSION >= 12002
@@ -33,19 +33,13 @@ namespace embree
func(i);
},context);
if (context.is_group_execution_cancelled())
- // -- GODOT start --
- // throw std::runtime_error("task cancelled");
- abort();
- // -- GODOT end --
+ throw std::runtime_error("task cancelled");
#else
tbb::parallel_for(Index(0),N,Index(1),[&](Index i) {
func(i);
});
if (tbb::task::self().is_cancelled())
- // -- GODOT start --
- // throw std::runtime_error("task cancelled");
- abort();
- // -- GODOT end --
+ throw std::runtime_error("task cancelled");
#endif
#elif defined(TASKING_PPL)
@@ -62,13 +56,13 @@ namespace embree
__forceinline void parallel_for( const Index first, const Index last, const Index minStepSize, const Func& func)
{
assert(first <= last);
-#if defined(TASKING_INTERNAL)
- TaskScheduler::spawn(first,last,minStepSize,func);
- if (!TaskScheduler::wait())
- // -- GODOT start --
- // throw std::runtime_error("task cancelled");
- abort();
- // -- GODOT end --
+#if defined(TASKING_INTERNAL) && !defined(TASKING_TBB)
+ TaskScheduler::TaskGroupContext context;
+ TaskScheduler::spawn(first,last,minStepSize,func,&context);
+ TaskScheduler::wait();
+ if (context.cancellingException != nullptr) {
+ std::rethrow_exception(context.cancellingException);
+ }
#elif defined(TASKING_TBB)
#if TBB_INTERFACE_VERSION >= 12002
@@ -77,19 +71,13 @@ namespace embree
func(range<Index>(r.begin(),r.end()));
},context);
if (context.is_group_execution_cancelled())
- // -- GODOT start --
- // throw std::runtime_error("task cancelled");
- abort();
- // -- GODOT end --
+ throw std::runtime_error("task cancelled");
#else
tbb::parallel_for(tbb::blocked_range<Index>(first,last,minStepSize),[&](const tbb::blocked_range<Index>& r) {
func(range<Index>(r.begin(),r.end()));
});
if (tbb::task::self().is_cancelled())
- // -- GODOT start --
- // throw std::runtime_error("task cancelled");
- abort();
- // -- GODOT end --
+ throw std::runtime_error("task cancelled");
#endif
#elif defined(TASKING_PPL)
@@ -121,19 +109,13 @@ namespace embree
func(i);
},tbb::simple_partitioner(),context);
if (context.is_group_execution_cancelled())
- // -- GODOT start --
- // throw std::runtime_error("task cancelled");
- abort();
- // -- GODOT end --
+ throw std::runtime_error("task cancelled");
#else
tbb::parallel_for(Index(0),N,Index(1),[&](Index i) {
func(i);
},tbb::simple_partitioner());
if (tbb::task::self().is_cancelled())
- // -- GODOT start --
- // throw std::runtime_error("task cancelled");
- abort();
- // -- GODOT end --
+ throw std::runtime_error("task cancelled");
#endif
}
@@ -148,19 +130,13 @@ namespace embree
func(i);
},ap,context);
if (context.is_group_execution_cancelled())
- // -- GODOT start --
- // throw std::runtime_error("task cancelled");
- abort();
- // -- GODOT end --
+ throw std::runtime_error("task cancelled");
#else
tbb::parallel_for(Index(0),N,Index(1),[&](Index i) {
func(i);
},ap);
if (tbb::task::self().is_cancelled())
- // -- GODOT start --
- // throw std::runtime_error("task cancelled");
- abort();
- // -- GODOT end --
+ throw std::runtime_error("task cancelled");
#endif
}