Eliminate the mlock logic entirely. It's caused a couple of issues lately and it turns out it wasn't even used!
This commit is contained in:
@@ -77,12 +77,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
RingBuffer<T> *resized(int newSize) const;
|
RingBuffer<T> *resized(int newSize) const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Lock the ring buffer into physical memory. Returns true
|
|
||||||
* for success.
|
|
||||||
*/
|
|
||||||
bool mlock();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset read and write pointers, thus emptying the buffer.
|
* Reset read and write pointers, thus emptying the buffer.
|
||||||
* Should be called from the write thread.
|
* Should be called from the write thread.
|
||||||
@@ -184,7 +178,6 @@ protected:
|
|||||||
std::atomic<int> m_writer;
|
std::atomic<int> m_writer;
|
||||||
std::atomic<int> m_reader;
|
std::atomic<int> m_reader;
|
||||||
const int m_size;
|
const int m_size;
|
||||||
bool m_mlocked;
|
|
||||||
|
|
||||||
int readSpaceFor(int w, int r) const {
|
int readSpaceFor(int w, int r) const {
|
||||||
int space;
|
int space;
|
||||||
@@ -209,8 +202,7 @@ template <typename T>
|
|||||||
RingBuffer<T>::RingBuffer(int n) :
|
RingBuffer<T>::RingBuffer(int n) :
|
||||||
m_buffer(allocate<T>(n + 1)),
|
m_buffer(allocate<T>(n + 1)),
|
||||||
m_writer(0),
|
m_writer(0),
|
||||||
m_size(n + 1),
|
m_size(n + 1)
|
||||||
m_mlocked(false)
|
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_RINGBUFFER
|
#ifdef DEBUG_RINGBUFFER
|
||||||
std::cerr << "RingBuffer<T>[" << this << "]::RingBuffer(" << n << ")" << std::endl;
|
std::cerr << "RingBuffer<T>[" << this << "]::RingBuffer(" << n << ")" << std::endl;
|
||||||
@@ -226,10 +218,6 @@ RingBuffer<T>::~RingBuffer()
|
|||||||
std::cerr << "RingBuffer<T>[" << this << "]::~RingBuffer" << std::endl;
|
std::cerr << "RingBuffer<T>[" << this << "]::~RingBuffer" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_mlocked) {
|
|
||||||
MUNLOCK((void *)m_buffer, m_size * sizeof(T));
|
|
||||||
}
|
|
||||||
|
|
||||||
deallocate(m_buffer);
|
deallocate(m_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,15 +251,6 @@ RingBuffer<T>::resized(int newSize) const
|
|||||||
return newBuffer;
|
return newBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
bool
|
|
||||||
RingBuffer<T>::mlock()
|
|
||||||
{
|
|
||||||
if (MLOCK((void *)m_buffer, m_size * sizeof(T))) return false;
|
|
||||||
m_mlocked = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void
|
void
|
||||||
RingBuffer<T>::reset()
|
RingBuffer<T>::reset()
|
||||||
|
|||||||
@@ -108,10 +108,6 @@ void gettimeofday(struct timeval *p, void *tz);
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
#define MLOCK(a,b) (void)1
|
|
||||||
#define MUNLOCK(a,b) (void)1
|
|
||||||
#define MUNLOCK_SAMPLEBLOCK(a) (void)1
|
|
||||||
|
|
||||||
namespace RubberBand {
|
namespace RubberBand {
|
||||||
extern void system_memorybarrier();
|
extern void system_memorybarrier();
|
||||||
}
|
}
|
||||||
@@ -119,14 +115,8 @@ extern void system_memorybarrier();
|
|||||||
|
|
||||||
#else // !_WIN32
|
#else // !_WIN32
|
||||||
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <dlfcn.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define MLOCK(a,b) mlock((char *)(a),(b))
|
|
||||||
#define MUNLOCK(a,b) (munlock((char *)(a),(b)) ? (perror("munlock failed"), 0) : 0)
|
|
||||||
#define MUNLOCK_SAMPLEBLOCK(a) do { if (!(a).empty()) { const float &b = *(a).begin(); MUNLOCK(&b, (a).capacity() * sizeof(float)); } } while(0);
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
# if defined __MAC_10_12
|
# if defined __MAC_10_12
|
||||||
# define MBARRIER() __sync_synchronize()
|
# define MBARRIER() __sync_synchronize()
|
||||||
|
|||||||
Reference in New Issue
Block a user