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:
Roman Beránek 2021-06-23 11:48:48 +02:00 committed by GitHub
parent 7a7108b2ad
commit e13535f822
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 80 additions and 95 deletions

View file

@ -10,12 +10,12 @@
#include <queue>
#include <atomic>
#include <mutex>
#include <thread>
#include <vector>
#include <chrono>
#include <condition_variable>
#include <tbb/mutex.h>
namespace Slic3r {
@ -85,7 +85,7 @@ class Mouse3DController
// m_input_queue is accessed by the background thread and by the UI thread. Access to m_input_queue
// is guarded with m_input_queue_mutex.
std::deque<QueueItem> m_input_queue;
mutable tbb::mutex m_input_queue_mutex;
mutable std::mutex m_input_queue_mutex;
#ifdef WIN32
// When the 3Dconnexion driver is running the system gets, by default, mouse wheel events when rotations around the X axis are detected.
@ -112,12 +112,12 @@ class Mouse3DController
#if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
Vec3d get_first_vector_of_type(unsigned int type) const {
tbb::mutex::scoped_lock lock(m_input_queue_mutex);
std::scoped_lock<std::mutex> lock(m_input_queue_mutex);
auto it = std::find_if(m_input_queue.begin(), m_input_queue.end(), [type](const QueueItem& item) { return item.type_or_buttons == type; });
return (it == m_input_queue.end()) ? Vec3d::Zero() : it->vector;
}
size_t input_queue_size_current() const {
tbb::mutex::scoped_lock lock(m_input_queue_mutex);
std::scoped_lock<std::mutex> lock(m_input_queue_mutex);
return m_input_queue.size();
}
std::atomic<size_t> input_queue_max_size_achieved;
@ -133,7 +133,7 @@ class Mouse3DController
// UI thread will read / write this copy.
Params m_params_ui;
bool m_params_ui_changed { false };
mutable tbb::mutex m_params_ui_mutex;
mutable std::mutex m_params_ui_mutex;
// This is a database of parametes of all 3DConnexion devices ever connected.
// This database is loaded from AppConfig on application start and it is stored to AppConfig on application exit.