summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-03-23 23:02:35 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2016-03-23 23:02:35 +0100
commit7e8e8b372ebce367ee6393a7666916bf813b8fdf (patch)
treeeab85ff0002cc1b9a9276f6636b6efbf0423bb4c /src
parenta06ac0793379358eb8095a859b617c85f166c15e (diff)
Use new Atomic class.
Diffstat (limited to 'src')
-rw-r--r--src/atomic.h6
-rw-r--r--src/settings.h35
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 <typename T>
-class Atomic<T, typename std::enable_if<std::is_trivially_copyable<T>::value>::type>
+class Atomic<T, typename std::enable_if<std::is_pod<T>::value>::type>
: public std::atomic<T> {
};
// else work around it using a mutex
template <typename T>
-class Atomic<T, typename std::enable_if<!std::is_trivially_copyable<T>::value>::type> {
+class Atomic<T, typename std::enable_if<!std::is_pod<T>::value>::type> {
public:
- using self_type = Atomic<T, typename std::enable_if<!std::is_trivially_copyable<T>::value>::type>;
+ using self_type = Atomic<T, typename std::enable_if<!std::is_pod<T>::value>::type>;
Atomic()
: data{}
diff --git a/src/settings.h b/src/settings.h
index 7cf5282..d899f0f 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -30,28 +30,25 @@
#include <string>
#include <cassert>
-class MyString {
-public:
- std::string value;
-};
+#include "atomic.h"
//! Engine settings
struct Settings
{
- std::atomic<bool> enable_velocity_modifier;
- std::atomic<float> velocity_modifier_falloff;
- std::atomic<float> velocity_modifier_weight;
+ Atomic<bool> enable_velocity_modifier;
+ Atomic<float> velocity_modifier_falloff;
+ Atomic<float> velocity_modifier_weight;
- std::atomic<bool> enable_velocity_randomiser;
- std::atomic<float> velocity_randomiser_weight;
+ Atomic<bool> enable_velocity_randomiser;
+ Atomic<float> velocity_randomiser_weight;
- std::atomic<double> samplerate;
+ Atomic<double> samplerate;
- std::atomic<bool> enable_resampling;
+ Atomic<bool> enable_resampling;
- std::atomic<int> number_of_files;
- std::atomic<int> number_of_files_loaded;
- //std::atomic<std::string> current_file;
+ Atomic<int> number_of_files;
+ Atomic<int> number_of_files_loaded;
+ Atomic<std::string> current_file;
};
@@ -59,7 +56,7 @@ struct Settings
template <typename T> class SettingRef
{
public:
- SettingRef(std::atomic<T>& value)
+ SettingRef(Atomic<T>& value)
: value(value)
{
// string isn't lock free either
@@ -79,8 +76,8 @@ public:
}
private:
- std::atomic<T>& value;
- std::atomic<T> cache;
+ Atomic<T>& value;
+ Atomic<T> cache;
};
//! Combined getter class.
@@ -99,7 +96,7 @@ struct SettingsGetter
SettingRef<int> number_of_files;
SettingRef<int> number_of_files_loaded;
- //SettingRef<std::string> current_file;
+ SettingRef<std::string> 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}
{
}
};