summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/video
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2016-03-01 10:05:59 +0100
committer Miodrag Milanovic <mmicko@gmail.com>2016-03-01 13:09:50 +0100
commit91c910e73c8b0faadf9381bc9626dbede88f04fe (patch)
tree648239678f6a3b5c4fb5e64309191b166cfe3e74 /src/devices/video
parent599570bf7f3a01baec9a56edf81075d82a5e4a51 (diff)
Use std::atomic and std::mutex where applicable (nw)
Diffstat (limited to 'src/devices/video')
-rw-r--r--src/devices/video/poly.h7
-rw-r--r--src/devices/video/polylgcy.cpp8
2 files changed, 8 insertions, 7 deletions
diff --git a/src/devices/video/poly.h b/src/devices/video/poly.h
index 2ecc72491f7..e5739e39570 100644
--- a/src/devices/video/poly.h
+++ b/src/devices/video/poly.h
@@ -38,6 +38,7 @@
#define __POLY_H__
#include <limits.h>
+#include <atomic>
//**************************************************************************
// DEBUGGING
@@ -165,7 +166,7 @@ private:
// internal unit of work
struct work_unit
{
- volatile UINT32 count_next; // number of scanlines and index of next item to process
+ std::atomic<UINT32> count_next; // number of scanlines and index of next item to process
polygon_info * polygon; // pointer to polygon
INT16 scanline; // starting scanline
UINT16 previtem; // index of previous item in the same bucket
@@ -405,7 +406,7 @@ void *poly_manager<_BaseType, _ObjectData, _MaxParams, _MaxPolys>::work_item_cal
{
orig_count_next = prevunit.count_next;
new_count_next = orig_count_next | (unitnum << 16);
- } while (compare_exchange32((volatile INT32 *)&prevunit.count_next, orig_count_next, new_count_next) != orig_count_next);
+ } while (!prevunit.count_next.compare_exchange_weak(orig_count_next, new_count_next, std::memory_order_release, std::memory_order_relaxed));
#if KEEP_POLY_STATISTICS
// track resolved conflicts
@@ -427,7 +428,7 @@ void *poly_manager<_BaseType, _ObjectData, _MaxParams, _MaxPolys>::work_item_cal
do
{
orig_count_next = unit.count_next;
- } while (compare_exchange32((volatile INT32 *)&unit.count_next, orig_count_next, 0) != orig_count_next);
+ } while (!unit.count_next.compare_exchange_weak(orig_count_next, 0, std::memory_order_release, std::memory_order_relaxed));
// if we have no more work to do, do nothing
orig_count_next >>= 16;
diff --git a/src/devices/video/polylgcy.cpp b/src/devices/video/polylgcy.cpp
index b5daf5a924b..25dd61aa733 100644
--- a/src/devices/video/polylgcy.cpp
+++ b/src/devices/video/polylgcy.cpp
@@ -10,7 +10,7 @@
#include "emu.h"
#include "polylgcy.h"
-
+#include <atomic>
/***************************************************************************
DEBUGGING
@@ -88,7 +88,7 @@ struct poly_section
struct work_unit_shared
{
polygon_info * polygon; /* pointer to polygon */
- volatile UINT32 count_next; /* number of scanlines and index of next item to process */
+ std::atomic<UINT32> count_next; /* number of scanlines and index of next item to process */
INT16 scanline; /* starting scanline and count */
UINT16 previtem; /* index of previous item in the same bucket */
#ifndef PTR64
@@ -1305,7 +1305,7 @@ static void *poly_item_callback(void *param, int threadid)
{
orig_count_next = prevunit->shared.count_next;
new_count_next = orig_count_next | (unitnum << 16);
- } while (compare_exchange32((volatile INT32 *)&prevunit->shared.count_next, orig_count_next, new_count_next) != orig_count_next);
+ } while (!prevunit->shared.count_next.compare_exchange_weak(orig_count_next, new_count_next, std::memory_order_release, std::memory_order_relaxed));
#if KEEP_STATISTICS
/* track resolved conflicts */
@@ -1336,7 +1336,7 @@ static void *poly_item_callback(void *param, int threadid)
do
{
orig_count_next = unit->shared.count_next;
- } while (compare_exchange32((volatile INT32 *)&unit->shared.count_next, orig_count_next, 0) != orig_count_next);
+ } while (!unit->shared.count_next.compare_exchange_weak(orig_count_next, 0, std::memory_order_release, std::memory_order_relaxed));
/* if we have no more work to do, do nothing */
orig_count_next >>= 16;