mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-26 10:11:10 -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
|
|
@ -84,7 +84,7 @@ void RemovableDriveManager::eject_drive()
|
|||
this->update();
|
||||
#endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
BOOST_LOG_TRIVIAL(info) << "Ejecting started";
|
||||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_drives_mutex);
|
||||
auto it_drive_data = this->find_last_save_path_drive_data();
|
||||
if (it_drive_data != m_current_drives.end()) {
|
||||
// get handle to device
|
||||
|
|
@ -130,7 +130,7 @@ std::string RemovableDriveManager::get_removable_drive_path(const std::string &p
|
|||
this->update();
|
||||
#endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
|
||||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_drives_mutex);
|
||||
if (m_current_drives.empty())
|
||||
return std::string();
|
||||
std::size_t found = path.find_last_of("\\");
|
||||
|
|
@ -146,7 +146,7 @@ std::string RemovableDriveManager::get_removable_drive_path(const std::string &p
|
|||
|
||||
std::string RemovableDriveManager::get_removable_drive_from_path(const std::string& path)
|
||||
{
|
||||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_drives_mutex);
|
||||
std::size_t found = path.find_last_of("\\");
|
||||
std::string new_path = path.substr(0, found);
|
||||
int letter = PathGetDriveNumberW(boost::nowide::widen(new_path).c_str());
|
||||
|
|
@ -287,7 +287,7 @@ void RemovableDriveManager::eject_drive()
|
|||
|
||||
DriveData drive_data;
|
||||
{
|
||||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_drives_mutex);
|
||||
auto it_drive_data = this->find_last_save_path_drive_data();
|
||||
if (it_drive_data == m_current_drives.end())
|
||||
return;
|
||||
|
|
@ -343,7 +343,7 @@ void RemovableDriveManager::eject_drive()
|
|||
if (success) {
|
||||
// Remove the drive_data from m_current drives, searching by value, not by pointer, as m_current_drives may get modified during
|
||||
// asynchronous execution on m_eject_thread.
|
||||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_drives_mutex);
|
||||
auto it = std::find(m_current_drives.begin(), m_current_drives.end(), drive_data);
|
||||
if (it != m_current_drives.end())
|
||||
m_current_drives.erase(it);
|
||||
|
|
@ -363,7 +363,7 @@ std::string RemovableDriveManager::get_removable_drive_path(const std::string &p
|
|||
std::size_t found = path.find_last_of("/");
|
||||
std::string new_path = found == path.size() - 1 ? path.substr(0, found) : path;
|
||||
|
||||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_drives_mutex);
|
||||
for (const DriveData &data : m_current_drives)
|
||||
if (search_for_drives_internal::compare_filesystem_id(new_path, data.path))
|
||||
return path;
|
||||
|
|
@ -379,7 +379,7 @@ std::string RemovableDriveManager::get_removable_drive_from_path(const std::stri
|
|||
new_path = new_path.substr(0, found);
|
||||
|
||||
// check if same filesystem
|
||||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_drives_mutex);
|
||||
for (const DriveData &drive_data : m_current_drives)
|
||||
if (search_for_drives_internal::compare_filesystem_id(new_path, drive_data.path))
|
||||
return drive_data.path;
|
||||
|
|
@ -454,7 +454,7 @@ RemovableDriveManager::RemovableDrivesStatus RemovableDriveManager::status()
|
|||
|
||||
RemovableDriveManager::RemovableDrivesStatus out;
|
||||
{
|
||||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_drives_mutex);
|
||||
out.has_eject =
|
||||
// Cannot control eject on Chromium.
|
||||
platform_flavor() != PlatformFlavor::LinuxOnChromium &&
|
||||
|
|
@ -470,17 +470,17 @@ RemovableDriveManager::RemovableDrivesStatus RemovableDriveManager::status()
|
|||
// Update is called from thread_proc() and from most of the public methods on demand.
|
||||
void RemovableDriveManager::update()
|
||||
{
|
||||
tbb::mutex::scoped_lock inside_update_lock;
|
||||
std::unique_lock<std::mutex> inside_update_lock(m_inside_update_mutex, std::defer_lock);
|
||||
#ifdef _WIN32
|
||||
// All wake up calls up to now are now consumed when the drive enumeration starts.
|
||||
m_wakeup = false;
|
||||
#endif // _WIN32
|
||||
if (inside_update_lock.try_acquire(m_inside_update_mutex)) {
|
||||
if (inside_update_lock.try_lock()) {
|
||||
// Got the lock without waiting. That means, the update was not running.
|
||||
// Run the update.
|
||||
std::vector<DriveData> current_drives = this->search_for_removable_drives();
|
||||
// Post update events.
|
||||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
std::scoped_lock<std::mutex> lock(m_drives_mutex);
|
||||
std::sort(current_drives.begin(), current_drives.end());
|
||||
if (current_drives != m_current_drives) {
|
||||
assert(m_callback_evt_handler);
|
||||
|
|
@ -491,7 +491,7 @@ void RemovableDriveManager::update()
|
|||
} else {
|
||||
// Acquiring the m_iniside_update lock failed, therefore another update is running.
|
||||
// Just block until the other instance of update() finishes.
|
||||
inside_update_lock.acquire(m_inside_update_mutex);
|
||||
inside_update_lock.lock();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue