From bd1434b6cfc59c37362ea6f462034f8265072c9a Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 23 Mar 2016 23:02:35 +0100 Subject: Use new Atomic class. --- src/atomic.h | 6 +++--- src/settings.h | 35 ++++++++++++++++------------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/atomic.h b/src/atomic.h index 11c87fc..f800f68 100644 --- a/src/atomic.h +++ b/src/atomic.h @@ -35,15 +35,15 @@ class Atomic; // use std::atomic if possible template -class Atomic::value>::type> +class Atomic::value>::type> : public std::atomic { }; // else work around it using a mutex template -class Atomic::value>::type> { +class Atomic::value>::type> { public: - using self_type = Atomic::value>::type>; + using self_type = Atomic::value>::type>; Atomic() : data{} diff --git a/src/settings.h b/src/settings.h index 4eb7dba..eb18909 100644 --- a/src/settings.h +++ b/src/settings.h @@ -30,28 +30,25 @@ #include #include -class MyString { -public: - std::string value; -}; +#include "atomic.h" //! Engine settings struct Settings { - std::atomic enable_velocity_modifier; - std::atomic velocity_modifier_falloff; - std::atomic velocity_modifier_weight; + Atomic enable_velocity_modifier; + Atomic velocity_modifier_falloff; + Atomic velocity_modifier_weight; - std::atomic enable_velocity_randomiser; - std::atomic velocity_randomiser_weight; + Atomic enable_velocity_randomiser; + Atomic velocity_randomiser_weight; - std::atomic samplerate; + Atomic samplerate; - std::atomic enable_resampling; + Atomic enable_resampling; - std::atomic number_of_files; - std::atomic number_of_files_loaded; - //std::atomic current_file; + Atomic number_of_files; + Atomic number_of_files_loaded; + Atomic current_file; }; @@ -59,7 +56,7 @@ struct Settings template class SettingRef { public: - SettingRef(std::atomic& value) + SettingRef(Atomic& value) : value(value) { // string isn't lock free either @@ -79,8 +76,8 @@ public: } private: - std::atomic& value; - std::atomic cache; + Atomic& value; + Atomic cache; }; //! Combined getter class. @@ -99,7 +96,7 @@ struct SettingsGetter SettingRef number_of_files; SettingRef number_of_files_loaded; - //SettingRef current_file; + SettingRef current_file; SettingsGetter(Settings& settings) : enable_velocity_modifier{settings.enable_velocity_modifier} @@ -111,7 +108,7 @@ struct SettingsGetter , enable_resampling{settings.enable_resampling} , number_of_files{settings.number_of_files} , number_of_files_loaded{settings.number_of_files_loaded} - //, current_file{settings.current_file} + , current_file{settings.current_file} { } }; -- cgit v1.2.3