mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-24 15:13:58 -06:00
drop deprecated TBB components (#6590)
Quite some time ago, many of the TBB components were deprecated in favor of their near-equivalents in the STL or, in the case of task_scheduler_init, were broken up and reconstituted under a less ad-hoc logic. Every time a header file marked deprecated gets included, a rather loud warning is emitted, which leads to a complete TBB's domination over the stderr stream during build time, making it harder to notice _legitimate_ warnings. Instead of merely muting the output with TBB_SUPPRESS_DEPRECATED_MESSAGES, perform a genuine migration away from the deprecated components with the added benefit of achieving a source compatibility with oneTBB, the successor to TBB which has dropped the deprecated API for good. What got replaced for what? | Deprecated | Replacement | | ------------------------------------- | --------------------------------------------- | | `tbb::atomic` | `std::atomic` | | `tbb::mutex` | `std::mutex` | | `tbb::mutex::scoped_lock` | `std::scoped_lock<std::mutex>` | | `tbb::mutex::scoped_lock` (empty) | `std::unique_lock<std::mutex>` (deferred) | | `tbb::task_scheduler_init` | `tbb::global_control` | | `tbb::this_thread` | `std::this_thread` | Signed-off-by: Roman Beranek <roman.beranek@prusa3d.com>
This commit is contained in:
parent
7a7108b2ad
commit
e13535f822
18 changed files with 80 additions and 95 deletions
|
@ -66,7 +66,7 @@ void update_maximum(std::atomic<T>& maximum_value, T const& value) noexcept
|
|||
|
||||
void Mouse3DController::State::append_translation(const Vec3d& translation, size_t input_queue_max_size)
|
||||
{
|
||||
tbb::mutex::scoped_lock lock(m_input_queue_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_input_queue_mutex);
|
||||
while (m_input_queue.size() >= input_queue_max_size)
|
||||
m_input_queue.pop_front();
|
||||
m_input_queue.emplace_back(QueueItem::translation(translation));
|
||||
|
@ -77,7 +77,7 @@ void Mouse3DController::State::append_translation(const Vec3d& translation, size
|
|||
|
||||
void Mouse3DController::State::append_rotation(const Vec3f& rotation, size_t input_queue_max_size)
|
||||
{
|
||||
tbb::mutex::scoped_lock lock(m_input_queue_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_input_queue_mutex);
|
||||
while (m_input_queue.size() >= input_queue_max_size)
|
||||
m_input_queue.pop_front();
|
||||
m_input_queue.emplace_back(QueueItem::rotation(rotation.cast<double>()));
|
||||
|
@ -92,7 +92,7 @@ void Mouse3DController::State::append_rotation(const Vec3f& rotation, size_t inp
|
|||
|
||||
void Mouse3DController::State::append_button(unsigned int id, size_t /* input_queue_max_size */)
|
||||
{
|
||||
tbb::mutex::scoped_lock lock(m_input_queue_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_input_queue_mutex);
|
||||
m_input_queue.emplace_back(QueueItem::buttons(id));
|
||||
#if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
|
||||
update_maximum(input_queue_max_size_achieved, m_input_queue.size());
|
||||
|
@ -274,7 +274,7 @@ void Mouse3DController::device_attached(const std::string &device)
|
|||
m_stop_condition.notify_all();
|
||||
m_device_str = format_device_string(vid, pid);
|
||||
if (auto it_params = m_params_by_device.find(m_device_str); it_params != m_params_by_device.end()) {
|
||||
tbb::mutex::scoped_lock lock(m_params_ui_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_params_ui_mutex);
|
||||
m_params = m_params_ui = it_params->second;
|
||||
}
|
||||
else
|
||||
|
@ -290,7 +290,7 @@ void Mouse3DController::device_detached(const std::string& device)
|
|||
int pid = 0;
|
||||
if (sscanf(device.c_str(), "\\\\?\\HID#VID_%x&PID_%x&", &vid, &pid) == 2) {
|
||||
if (std::find(_3DCONNEXION_VENDORS.begin(), _3DCONNEXION_VENDORS.end(), vid) != _3DCONNEXION_VENDORS.end()) {
|
||||
tbb::mutex::scoped_lock lock(m_params_ui_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_params_ui_mutex);
|
||||
m_params_by_device[format_device_string(vid, pid)] = m_params_ui;
|
||||
}
|
||||
}
|
||||
|
@ -301,12 +301,12 @@ void Mouse3DController::device_detached(const std::string& device)
|
|||
// Filter out mouse scroll events produced by the 3DConnexion driver.
|
||||
bool Mouse3DController::State::process_mouse_wheel()
|
||||
{
|
||||
tbb::mutex::scoped_lock lock(m_input_queue_mutex);
|
||||
if (m_mouse_wheel_counter == 0)
|
||||
// No 3DConnexion rotation has been captured since the last mouse scroll event.
|
||||
std::scoped_lock<std::mutex> lock(m_input_queue_mutex);
|
||||
if (m_mouse_wheel_counter == 0)
|
||||
// No 3DConnexion rotation has been captured since the last mouse scroll event.
|
||||
return false;
|
||||
if (std::find_if(m_input_queue.begin(), m_input_queue.end(), [](const QueueItem &item){ return item.is_rotation(); }) != m_input_queue.end()) {
|
||||
// There is a rotation stored in the queue. Suppress one mouse scroll event.
|
||||
// There is a rotation stored in the queue. Suppress one mouse scroll event.
|
||||
-- m_mouse_wheel_counter;
|
||||
return true;
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ bool Mouse3DController::State::apply(const Mouse3DController::Params ¶ms, Ca
|
|||
std::deque<QueueItem> input_queue;
|
||||
{
|
||||
// Atomically move m_input_queue to input_queue.
|
||||
tbb::mutex::scoped_lock lock(m_input_queue_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_input_queue_mutex);
|
||||
input_queue = std::move(m_input_queue);
|
||||
m_input_queue.clear();
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ bool Mouse3DController::apply(Camera& camera)
|
|||
|
||||
#ifdef _WIN32
|
||||
{
|
||||
tbb::mutex::scoped_lock lock(m_params_ui_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_params_ui_mutex);
|
||||
if (m_params_ui_changed) {
|
||||
m_params = m_params_ui;
|
||||
m_params_ui_changed = false;
|
||||
|
@ -439,7 +439,7 @@ void Mouse3DController::render_settings_dialog(GLCanvas3D& canvas) const
|
|||
Params params_copy;
|
||||
bool params_changed = false;
|
||||
{
|
||||
tbb::mutex::scoped_lock lock(m_params_ui_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_params_ui_mutex);
|
||||
params_copy = m_params_ui;
|
||||
}
|
||||
|
||||
|
@ -557,7 +557,7 @@ void Mouse3DController::render_settings_dialog(GLCanvas3D& canvas) const
|
|||
|
||||
if (params_changed) {
|
||||
// Synchronize front end parameters to back end.
|
||||
tbb::mutex::scoped_lock lock(m_params_ui_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_params_ui_mutex);
|
||||
auto pthis = const_cast<Mouse3DController*>(this);
|
||||
#if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
|
||||
if (params_copy.input_queue_max_size != params_copy.input_queue_max_size)
|
||||
|
@ -578,7 +578,7 @@ void Mouse3DController::connected(std::string device_name)
|
|||
m_device_str = device_name;
|
||||
// Copy the parameters for m_device_str into the current parameters.
|
||||
if (auto it_params = m_params_by_device.find(m_device_str); it_params != m_params_by_device.end()) {
|
||||
tbb::mutex::scoped_lock lock(m_params_ui_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_params_ui_mutex);
|
||||
m_params = m_params_ui = it_params->second;
|
||||
}
|
||||
m_connected = true;
|
||||
|
@ -589,7 +589,7 @@ void Mouse3DController::disconnected()
|
|||
// Copy the current parameters for m_device_str into the parameter database.
|
||||
assert(m_connected == ! m_device_str.empty());
|
||||
if (m_connected) {
|
||||
tbb::mutex::scoped_lock lock(m_params_ui_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_params_ui_mutex);
|
||||
m_params_by_device[m_device_str] = m_params_ui;
|
||||
m_device_str.clear();
|
||||
m_connected = false;
|
||||
|
@ -613,7 +613,7 @@ bool Mouse3DController::handle_input(const DataPacketAxis& packet)
|
|||
{
|
||||
// Synchronize parameters between the UI thread and the background thread.
|
||||
//FIXME is this necessary on OSX? Are these notifications triggered from the main thread or from a worker thread?
|
||||
tbb::mutex::scoped_lock lock(m_params_ui_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_params_ui_mutex);
|
||||
if (m_params_ui_changed) {
|
||||
m_params = m_params_ui;
|
||||
m_params_ui_changed = false;
|
||||
|
@ -721,7 +721,7 @@ void Mouse3DController::run()
|
|||
|
||||
for (;;) {
|
||||
{
|
||||
tbb::mutex::scoped_lock lock(m_params_ui_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_params_ui_mutex);
|
||||
if (m_stop)
|
||||
break;
|
||||
if (m_params_ui_changed) {
|
||||
|
@ -986,7 +986,7 @@ bool Mouse3DController::connect_device()
|
|||
#endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
|
||||
// Copy the parameters for m_device_str into the current parameters.
|
||||
if (auto it_params = m_params_by_device.find(m_device_str); it_params != m_params_by_device.end()) {
|
||||
tbb::mutex::scoped_lock lock(m_params_ui_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_params_ui_mutex);
|
||||
m_params = m_params_ui = it_params->second;
|
||||
}
|
||||
}
|
||||
|
@ -1011,7 +1011,7 @@ void Mouse3DController::disconnect_device()
|
|||
BOOST_LOG_TRIVIAL(info) << "Disconnected device: " << m_device_str;
|
||||
// Copy the current parameters for m_device_str into the parameter database.
|
||||
{
|
||||
tbb::mutex::scoped_lock lock(m_params_ui_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_params_ui_mutex);
|
||||
m_params_by_device[m_device_str] = m_params_ui;
|
||||
}
|
||||
m_device_str.clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue