summaryrefslogtreecommitdiff
path: root/cad/PrusaSlicer/files/patch-src_libslic3r_Thread.cpp
diff options
context:
space:
mode:
authorSteve Wills <swills@FreeBSD.org>2021-09-15 12:30:06 +0300
committerMichael Zhilin <mizhka@FreeBSD.org>2021-09-15 12:32:10 +0300
commit8a4af427075f66baf4fedbbaba03ffc7f3f1f536 (patch)
tree886f4cfa57d18553b607758842186da88a1a9228 /cad/PrusaSlicer/files/patch-src_libslic3r_Thread.cpp
parentwww/deno: Update to 1.14.0 (diff)
cad/PrusaSlicer: Update to 2.3.3
- Update to 2.3.3 - Change the dependency from devel/tbb to devel/onetbb ChangeLog: https://github.com/prusa3d/PrusaSlicer/releases/tag/version_2.3.3 PR: 258483 Submitted by: Steve Wills <swills@FreeBSD.org> Reported by: teodorsigaev@gmail.com (tested), eborisch+FreeBSD@gmail.com (tested)
Diffstat (limited to 'cad/PrusaSlicer/files/patch-src_libslic3r_Thread.cpp')
-rw-r--r--cad/PrusaSlicer/files/patch-src_libslic3r_Thread.cpp71
1 files changed, 35 insertions, 36 deletions
diff --git a/cad/PrusaSlicer/files/patch-src_libslic3r_Thread.cpp b/cad/PrusaSlicer/files/patch-src_libslic3r_Thread.cpp
index d48272fed2fe..23d0e75df413 100644
--- a/cad/PrusaSlicer/files/patch-src_libslic3r_Thread.cpp
+++ b/cad/PrusaSlicer/files/patch-src_libslic3r_Thread.cpp
@@ -2,45 +2,44 @@ Note that this patch may be removed after FreeBSD 11.x EoL
as latest FreeBSD versions have proper
pthread_setname_np/pthread_getname_np support.
---- src/libslic3r/Thread.cpp.orig 2021-01-11 13:01:51 UTC
+--- src/libslic3r/Thread.cpp.orig 2021-07-16 10:14:03 UTC
+++ src/libslic3r/Thread.cpp
-@@ -4,6 +4,7 @@
- #else
- // any posix system
- #include <pthread.h>
-+ #include <pthread_np.h>
- #endif
-
+@@ -9,10 +9,10 @@
#include <atomic>
-@@ -161,26 +162,27 @@ std::optional<std::string> get_current_thread_name()
- // posix
- bool set_thread_name(std::thread &thread, const char *thread_name)
- {
-- pthread_setname_np(thread.native_handle(), thread_name);
-+ pthread_set_name_np(thread.native_handle(), thread_name);
- return true;
- }
+ #include <condition_variable>
+ #include <mutex>
++#include <thread>
++#include <tbb/global_control.h>
+ #include <tbb/parallel_for.h>
+-#include <tbb/tbb_thread.h>
+ #include <tbb/task_arena.h>
+-#include <tbb/task_scheduler_init.h>
- bool set_thread_name(boost::thread &thread, const char *thread_name)
- {
-- pthread_setname_np(thread.native_handle(), thread_name);
-+ pthread_set_name_np(thread.native_handle(), thread_name);
- return true;
- }
+ #include "Thread.hpp"
- bool set_current_thread_name(const char *thread_name)
- {
-- pthread_setname_np(pthread_self(), thread_name);
-+ pthread_set_name_np(pthread_self(), thread_name);
- return true;
- }
+@@ -206,13 +206,13 @@ void name_tbb_thread_pool_threads()
+ nthreads = 1;
+ #endif
- std::optional<std::string> get_current_thread_name()
- {
- char buf[16];
-- return std::string(pthread_getname_np(pthread_self(), buf, 16) == 0 ? buf : "");
-+ pthread_get_name_np(pthread_self(), buf, 16);
-+ return std::string(buf);
- }
+- if (nthreads != nthreads_hw)
+- new tbb::task_scheduler_init(int(nthreads));
++ if (nthreads != nthreads_hw)
++ tbb::global_control(tbb::global_control::max_allowed_parallelism, nthreads);
- #endif
+ std::atomic<size_t> nthreads_running(0);
+ std::condition_variable cv;
+ std::mutex cv_m;
+- auto master_thread_id = tbb::this_tbb_thread::get_id();
++ auto master_thread_id = std::this_thread::get_id();
+ tbb::parallel_for(
+ tbb::blocked_range<size_t>(0, nthreads, 1),
+ [&nthreads_running, nthreads, &master_thread_id, &cv, &cv_m](const tbb::blocked_range<size_t> &range) {
+@@ -226,7 +226,7 @@ void name_tbb_thread_pool_threads()
+ std::unique_lock<std::mutex> lk(cv_m);
+ cv.wait(lk, [&nthreads_running, nthreads]{return nthreads_running == nthreads;});
+ }
+- auto thread_id = tbb::this_tbb_thread::get_id();
++ auto thread_id = std::this_thread::get_id();
+ if (thread_id == master_thread_id) {
+ // The calling thread runs the 0'th task.
+ assert(range.begin() == 0);