summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-09-20 15:26:45 -0400
committerDavid Robillard <d@drobilla.net>2016-09-26 13:09:10 -0400
commitf8bf77d3c3b77830aedafb9ebb5cdadfea7ed07a (patch)
tree4b191728aa88b9e83080b07f4e391a62229168e9
parent537debda2bba0f97734602a95d412569fb607efb (diff)
downloadraul-f8bf77d3c3b77830aedafb9ebb5cdadfea7ed07a.tar.gz
raul-f8bf77d3c3b77830aedafb9ebb5cdadfea7ed07a.tar.bz2
raul-f8bf77d3c3b77830aedafb9ebb5cdadfea7ed07a.zip
Remove features now provided by C++11
-rw-r--r--NEWS3
-rw-r--r--raul/RingBuffer.hpp10
-rw-r--r--raul/ThreadVar.hpp75
-rw-r--r--raul/barrier.hpp56
4 files changed, 7 insertions, 137 deletions
diff --git a/NEWS b/NEWS
index 3eef2d4..3c36ddc 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ raul (0.8.5) unstable;
* Remove boost dependency
* Remove OSC and RDF library dependent code
* Remove remaining library code, now header only
+ * Remove features now provided by C++11
* Improve RingBuffer
* Add ThreadVar, a thread-specific variable class
* Implement Semaphore for Windows
@@ -12,7 +13,7 @@ raul (0.8.5) unstable;
* Add INSTALL file
* Update license to GPL3+
- -- David Robillard <d@drobilla.net> Wed, 25 Dec 2013 15:15:08 -0500
+ -- David Robillard <d@drobilla.net> Mon, 26 Sep 2016 13:08:52 -0400
raul (0.8.0) stable;
diff --git a/raul/RingBuffer.hpp b/raul/RingBuffer.hpp
index eb86036..1ec5e4e 100644
--- a/raul/RingBuffer.hpp
+++ b/raul/RingBuffer.hpp
@@ -18,12 +18,12 @@
#define RAUL_RING_BUFFER_HPP
#include <assert.h>
+#include <atomic>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "raul/Noncopyable.hpp"
-#include "raul/barrier.hpp"
namespace Raul {
@@ -103,7 +103,7 @@ public:
const uint32_t w = _write_head;
if (peek_internal(r, w, size, dst)) {
- Raul::barrier();
+ std::atomic_thread_fence(std::memory_order_acquire);
_read_head = (r + size) & _size_mask;
return size;
} else {
@@ -121,7 +121,7 @@ public:
return 0;
}
- Raul::barrier();
+ std::atomic_thread_fence(std::memory_order_acquire);
_read_head = (r + size) & _size_mask;
return size;
}
@@ -138,7 +138,7 @@ public:
if (w + size <= _size) {
memcpy(&_buf[w], src, size);
- Raul::barrier();
+ std::atomic_thread_fence(std::memory_order_release);
_write_head = (w + size) & _size_mask;
} else {
const uint32_t this_size = _size - w;
@@ -146,7 +146,7 @@ public:
assert(w + this_size <= _size);
memcpy(&_buf[w], src, this_size);
memcpy(&_buf[0], (const char*)src + this_size, size - this_size);
- Raul::barrier();
+ std::atomic_thread_fence(std::memory_order_release);
_write_head = size - this_size;
}
diff --git a/raul/ThreadVar.hpp b/raul/ThreadVar.hpp
deleted file mode 100644
index fa714bd..0000000
--- a/raul/ThreadVar.hpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- This file is part of Raul.
- Copyright 2007-2016 David Robillard <http://drobilla.net>
-
- Raul is free software: you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation, either version 3 of the License, or any later version.
-
- Raul is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Raul. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef RAUL_THREADVAR_HPP
-#define RAUL_THREADVAR_HPP
-
-#include <pthread.h>
-
-#include "raul/Noncopyable.hpp"
-
-namespace Raul {
-
-/** Thread-specific variable.
- *
- * A ThreadVar is a variable which has a different value for each thread.
- */
-template<typename T>
-class ThreadVar : public Noncopyable
-{
-public:
- explicit ThreadVar(const T& default_value)
- : _default_value(default_value)
- {
- pthread_key_create(&_key, destroy_value);
- }
-
- ~ThreadVar() {
- T* val = (T*)pthread_getspecific(_key);
- delete val;
- pthread_key_delete(_key);
- }
-
- /** Set the value for the calling thread. */
- ThreadVar& operator=(const T& value) {
- T* val = (T*)pthread_getspecific(_key);
- if (val) {
- *val = value;
- } else {
- val = new T(value);
- pthread_setspecific(_key, val);
- }
- return *this;
- }
-
- /** Get the value for the calling thread. */
- operator T() const {
- T* val = (T*)pthread_getspecific(_key);
- return val ? *val : _default_value;
- }
-
-private:
- static void destroy_value(void* ptr) {
- delete (T*)ptr;
- }
-
- const T _default_value;
- pthread_key_t _key;
-};
-
-} // namespace Raul
-
-#endif // RAUL_THREADVAR_HPP
diff --git a/raul/barrier.hpp b/raul/barrier.hpp
deleted file mode 100644
index 952278e..0000000
--- a/raul/barrier.hpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- This file is part of Raul.
- Copyright 2012 David Robillard <http://drobilla.net>
-
- Raul is free software: you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation, either version 3 of the License, or any later version.
-
- Raul is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Raul. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef RAUL_BARRIER_HPP
-#define RAUL_BARRIER_HPP
-
-#if defined(__APPLE__)
-#include <libkern/OSAtomic.h>
-
-namespace Raul {
-static inline void barrier() {
- OSMemoryBarrier();
-}
-}
-
-#elif defined(_WIN32)
-#include <windows.h>
-
-namespace Raul {
-static inline void barrier() {
- MemoryBarrier();
-}
-}
-
-#elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
-
-namespace Raul {
-static inline void barrier() {
- __sync_synchronize();
-}
-}
-
-#else
-#pragma message("warning: No memory barriers, possible SMP bugs")
-
-namespace Raul {
-static inline void barrier() {
-}
-}
-
-#endif
-
-#endif // RAUL_BARRIER_HPP