Fix call to compare_exchange_strong() in Spatial_lock_grid_3.h

This commit is contained in:
Maxime Gimeno 2020-01-14 15:43:22 +01:00
parent 85712ba28c
commit e3a20071a1
1 changed files with 2 additions and 3 deletions

View File

@ -476,8 +476,7 @@ public:
bool try_lock_cell_impl(int cell_index)
{
bool v1 = true, v2 = false;
bool old_value = m_grid[cell_index].compare_exchange_strong(v1,v2);
if (old_value == false)
if(m_grid[cell_index].compare_exchange_strong(v2,v1))
{
get_thread_local_grid()[cell_index] = true;
m_tls_locked_cells.local().push_back(cell_index);
@ -544,7 +543,7 @@ public:
if (no_spin)
{
unsigned int old_value = 0;
if(!m_grid[cell_index].compare_exchange_strong(old_value, this_thread_priority))
if(m_grid[cell_index].compare_exchange_strong(old_value, this_thread_priority))
{
get_thread_local_grid()[cell_index] = true;
m_tls_locked_cells.local().push_back(cell_index);