Use std::atomic in nl_lists.h with OpenMP

This commit is contained in:
Vas Crabb 2016-03-22 12:41:40 +11:00
parent 95f8658286
commit f83078d8bf
2 changed files with 7 additions and 4 deletions

2
.gitignore vendored
View File

@ -31,7 +31,7 @@
!/makefile
!/mame.doxygen
!/*.md
!/*.bdc
!/*.bdf
!/LICENSE
/.idea
regtests/chdman/temp

View File

@ -13,6 +13,9 @@
#include "nl_config.h"
#include "plib/plists.h"
#include <atomic>
// ----------------------------------------------------------------------------------------
// timed queue
// ----------------------------------------------------------------------------------------
@ -62,7 +65,7 @@ namespace netlist
{
#if HAS_OPENMP && USE_OPENMP
/* Lock */
while (atomic_exchange32(&m_lock, 1)) { }
while (m_lock.exchange(1)) { }
#endif
const _Time &t = e.exec_time();
entry_t * i = m_end++;
@ -94,7 +97,7 @@ namespace netlist
{
/* Lock */
#if HAS_OPENMP && USE_OPENMP
while (atomic_exchange32(&m_lock, 1)) { }
while (m_lock.exchange(1)) { }
#endif
for (entry_t * i = m_end - 1; i > &m_list[0]; i--)
{
@ -143,7 +146,7 @@ namespace netlist
private:
#if HAS_OPENMP && USE_OPENMP
volatile INT32 m_lock;
volatile std::atomic<int> m_lock;
#endif
entry_t * m_end;
parray_t<entry_t> m_list;