mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 06:21:26 +12:00
rsx: Fix race conditions on removals
This commit is contained in:
parent
00f1b2bfa7
commit
236ac7d062
2 changed files with 19 additions and 17 deletions
|
@ -52,7 +52,7 @@ namespace rsx
|
||||||
{
|
{
|
||||||
m_list_mutex.unlock_shared();
|
m_list_mutex.unlock_shared();
|
||||||
|
|
||||||
if (!m_uids_to_remove.empty() || !m_type_ids_to_remove.empty())
|
if (m_pending_removals_count > 0)
|
||||||
{
|
{
|
||||||
std::lock_guard lock(m_list_mutex);
|
std::lock_guard lock(m_list_mutex);
|
||||||
cleanup_internal();
|
cleanup_internal();
|
||||||
|
@ -78,18 +78,19 @@ namespace rsx
|
||||||
{
|
{
|
||||||
remove_uid(uid);
|
remove_uid(uid);
|
||||||
m_list_mutex.unlock();
|
m_list_mutex.unlock();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
// Enqueue
|
||||||
m_uids_to_remove.push_back(uid);
|
m_uids_to_remove.push(uid);
|
||||||
}
|
m_pending_removals_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_manager::dispose(const std::vector<u32>& uids)
|
void display_manager::dispose(const std::vector<u32>& uids)
|
||||||
{
|
{
|
||||||
std::lock_guard lock(m_list_mutex);
|
std::lock_guard lock(m_list_mutex);
|
||||||
|
|
||||||
if (!m_uids_to_remove.empty() || !m_type_ids_to_remove.empty())
|
if (m_pending_removals_count > 0)
|
||||||
{
|
{
|
||||||
cleanup_internal();
|
cleanup_internal();
|
||||||
}
|
}
|
||||||
|
@ -144,18 +145,17 @@ namespace rsx
|
||||||
|
|
||||||
void display_manager::cleanup_internal()
|
void display_manager::cleanup_internal()
|
||||||
{
|
{
|
||||||
for (const auto& uid : m_uids_to_remove)
|
for (auto&& uid : m_uids_to_remove.pop_all())
|
||||||
{
|
{
|
||||||
remove_uid(uid);
|
remove_uid(uid);
|
||||||
|
m_pending_removals_count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& type_id : m_type_ids_to_remove)
|
for (auto&& type_id : m_type_ids_to_remove.pop_all())
|
||||||
{
|
{
|
||||||
remove_type(type_id);
|
remove_type(type_id);
|
||||||
|
m_pending_removals_count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_uids_to_remove.clear();
|
|
||||||
m_type_ids_to_remove.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_manager::on_overlay_activated(const std::shared_ptr<overlay>& /*item*/)
|
void display_manager::on_overlay_activated(const std::shared_ptr<overlay>& /*item*/)
|
||||||
|
|
|
@ -24,8 +24,9 @@ namespace rsx
|
||||||
std::vector<std::shared_ptr<overlay>> m_dirty_list;
|
std::vector<std::shared_ptr<overlay>> m_dirty_list;
|
||||||
|
|
||||||
shared_mutex m_list_mutex;
|
shared_mutex m_list_mutex;
|
||||||
std::vector<u32> m_uids_to_remove;
|
lf_queue<u32> m_uids_to_remove;
|
||||||
std::vector<u32> m_type_ids_to_remove;
|
lf_queue<u32> m_type_ids_to_remove;
|
||||||
|
atomic_t<u32> m_pending_removals_count = 0;
|
||||||
|
|
||||||
bool remove_type(u32 type_id);
|
bool remove_type(u32 type_id);
|
||||||
|
|
||||||
|
@ -92,11 +93,12 @@ namespace rsx
|
||||||
{
|
{
|
||||||
remove_type(type_id);
|
remove_type(type_id);
|
||||||
m_list_mutex.unlock();
|
m_list_mutex.unlock();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
// Enqueue
|
||||||
m_type_ids_to_remove.push_back(type_id);
|
m_type_ids_to_remove.push(type_id);
|
||||||
}
|
m_pending_removals_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// True if any visible elements to draw exist
|
// True if any visible elements to draw exist
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue