summaryrefslogtreecommitdiff
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-29 22:43:34 +0200
commit8d2dd0685e130b1e6ad479b30fd3e96581763e60 (patch)
treec5a38e491cf85953a0a9396a0345b3bb18409b95
parente584e1b0343542e08ba834307dab8aa3a745d0cf (diff)
Use new Atomic class.
-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 4eb7dba..eb18909 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}
{
}
};