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:
Chris Cannam
2022-09-26 10:11:16 +01:00
parent 0eaca1711c
commit 57d59b4c7a
2 changed files with 1 additions and 32 deletions

View File

@@ -77,12 +77,6 @@ public:
*/
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.
* Should be called from the write thread.
@@ -184,7 +178,6 @@ protected:
std::atomic<int> m_writer;
std::atomic<int> m_reader;
const int m_size;
bool m_mlocked;
int readSpaceFor(int w, int r) const {
int space;
@@ -209,8 +202,7 @@ template <typename T>
RingBuffer<T>::RingBuffer(int n) :
m_buffer(allocate<T>(n + 1)),
m_writer(0),
m_size(n + 1),
m_mlocked(false)
m_size(n + 1)
{
#ifdef DEBUG_RINGBUFFER
std::cerr << "RingBuffer<T>[" << this << "]::RingBuffer(" << n << ")" << std::endl;
@@ -226,10 +218,6 @@ RingBuffer<T>::~RingBuffer()
std::cerr << "RingBuffer<T>[" << this << "]::~RingBuffer" << std::endl;
#endif
if (m_mlocked) {
MUNLOCK((void *)m_buffer, m_size * sizeof(T));
}
deallocate(m_buffer);
}
@@ -263,15 +251,6 @@ RingBuffer<T>::resized(int newSize) const
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>
void
RingBuffer<T>::reset()