From dff5bda202a70807aaff4db90a291bb40aaa9950 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 2 Mar 2017 16:31:29 +0100 Subject: The Shiny profiler is not thread safe. Disable parallelization if SLIC3R_PROFILE is enabled. --- xs/src/libslic3r/libslic3r.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'xs') diff --git a/xs/src/libslic3r/libslic3r.h b/xs/src/libslic3r/libslic3r.h index c1223f5c2..0fe3ca53a 100644 --- a/xs/src/libslic3r/libslic3r.h +++ b/xs/src/libslic3r/libslic3r.h @@ -121,12 +121,20 @@ template void parallelize(std::queue queue, boost::function func, int threads_count = boost::thread::hardware_concurrency()) { - if (threads_count == 0) threads_count = 2; +#ifdef SLIC3R_PROFILE + while (! queue.empty()) { + func(queue.front()); + queue.pop(); + } +#else + if (threads_count == 0) + threads_count = 2; boost::mutex queue_mutex; boost::thread_group workers; for (int i = 0; i < std::min(threads_count, int(queue.size())); ++ i) workers.add_thread(new boost::thread(&_parallelize_do, &queue, &queue_mutex, func)); workers.join_all(); +#endif } template void -- cgit v1.2.3