update to latest version

This commit is contained in:
QIDI TECH
2023-06-27 11:07:34 +08:00
parent afe5c54367
commit dd0d4c8c4a
80 changed files with 1931 additions and 599 deletions

View File

@@ -4,6 +4,7 @@
#include <utility>
#include <string>
#include <thread>
#include <random>
#include <boost/thread.hpp>
#include <tbb/task_scheduler_observer.h>
@@ -67,6 +68,27 @@ template<class Fn> inline boost::thread create_thread(Fn &&fn)
return create_thread(attrs, std::forward<Fn>(fn));
}
class ThreadData {
public:
std::mt19937& random_generator() {
if (! m_random_generator_initialized) {
std::random_device rd;
m_random_generator.seed(rd());
m_random_generator_initialized = true;
}
return m_random_generator;
}
void tbb_worker_thread_set_c_locales();
private:
std::mt19937 m_random_generator;
bool m_random_generator_initialized { false };
bool m_tbb_worker_thread_c_locales_set { false };
};
ThreadData& thread_data();
// For unknown reasons and in sporadic cases when GCode export is processing, some participating thread
// in tbb::parallel_pipeline has not set locales to "C", probably because this thread is newly spawned.
// So in this class method on_scheduler_entry is called for every thread before it starts participating
@@ -79,11 +101,7 @@ class TBBLocalesSetter : public tbb::task_scheduler_observer
public:
TBBLocalesSetter() { this->observe(true); }
~TBBLocalesSetter() override { this->observe(false); };
void on_scheduler_entry(bool is_worker) override;
private:
tbb::enumerable_thread_specific<bool, tbb::cache_aligned_allocator<bool>, tbb::ets_key_usage_type::ets_key_per_instance> m_is_locales_sets{ false };
void on_scheduler_entry(bool /* is_worker */) override { thread_data().tbb_worker_thread_set_c_locales(); }
};
}