Commit 590998c9 authored by Nghia Truong's avatar Nghia Truong
Browse files

BUG: Fix deadlock of SpinLock when atomic_flag member was not properly initialized

parent 669cdb51
......@@ -36,15 +36,22 @@ class SpinLock
{
public:
///
/// \brief Constructor
/// \brief Default constructor, initializes the atomic_flag member to memory_order_release state
///
SpinLock() = default;
SpinLock()
{
unlock();
}
///
/// \brief Copy constructor, must be implemented as an empty function
/// because the member variable of type std::atomic_flag has copy constructor deleted
/// because the member variable of type std::atomic_flag has copy constructor deleted.
/// In addition, the constructor initializes the atomic_flag member to memory_order_release state
///
SpinLock(const SpinLock&) {}
SpinLock(const SpinLock&)
{
unlock();
}
///
/// \brief Start a thread-safe region, where only one thread can execute at a time until
......
......@@ -64,9 +64,6 @@ void GridBasedNeighborSearch::getNeighbors(std::vector<std::vector<size_t>>& res
[&](const size_t cellIdx)
{
m_Grid.getCellData(cellIdx).particleIndices.resize(0);
// This line is not logically necessary, but it is needed due to a bug in MSVC
m_Grid.getCellData(cellIdx).lock.unlock();
});
// collect particle indices of points in setB into their corresponding cells
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment