From e3a20071a1de52e6de3d68cf98cb58094891d0bd Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 14 Jan 2020 15:43:22 +0100 Subject: [PATCH] Fix call to compare_exchange_strong() in Spatial_lock_grid_3.h --- STL_Extension/include/CGAL/Spatial_lock_grid_3.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/STL_Extension/include/CGAL/Spatial_lock_grid_3.h b/STL_Extension/include/CGAL/Spatial_lock_grid_3.h index 467a4abac4e..4ee20abd9f1 100644 --- a/STL_Extension/include/CGAL/Spatial_lock_grid_3.h +++ b/STL_Extension/include/CGAL/Spatial_lock_grid_3.h @@ -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);