summaryrefslogtreecommitdiff
path: root/ringbuffer.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2012-09-22 11:52:33 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2012-09-22 11:52:33 +0200
commit72c03260d77a0de52ed57992e374f26211fe2063 (patch)
treeea61de60ff2567caee18e1b4a2afbb563de56e6f /ringbuffer.c
parente898a28258ac97cc15f875fb8fa9b274266f6d01 (diff)
downloadvdr-72c03260d77a0de52ed57992e374f26211fe2063.tar.gz
vdr-72c03260d77a0de52ed57992e374f26211fe2063.tar.bz2
The new class cIoThrottle is used to allow I/O intense threads to temporarily suspend their activities in case buffers run full
Diffstat (limited to 'ringbuffer.c')
-rw-r--r--ringbuffer.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/ringbuffer.c b/ringbuffer.c
index 269623d4..abe78990 100644
--- a/ringbuffer.c
+++ b/ringbuffer.c
@@ -7,7 +7,7 @@
* Parts of this file were inspired by the 'ringbuffy.c' from the
* LinuxDVB driver (see linuxtv.org).
*
- * $Id: ringbuffer.c 2.4 2012/09/17 08:23:43 kls Exp $
+ * $Id: ringbuffer.c 2.5 2012/09/22 11:26:49 kls Exp $
*/
#include "ringbuffer.h"
@@ -20,6 +20,8 @@
#define OVERFLOWREPORTDELTA 5 // seconds between reports
#define PERCENTAGEDELTA 10
#define PERCENTAGETHRESHOLD 70
+#define IOTHROTTLELOW 20
+#define IOTHROTTLEHIGH 50
cRingBuffer::cRingBuffer(int Size, bool Statistics)
{
@@ -31,10 +33,12 @@ cRingBuffer::cRingBuffer(int Size, bool Statistics)
putTimeout = getTimeout = 0;
lastOverflowReport = 0;
overflowCount = overflowBytes = 0;
+ ioThrottle = NULL;
}
cRingBuffer::~cRingBuffer()
{
+ delete ioThrottle;
if (statistics)
dsyslog("buffer stats: %d (%d%%) used", maxFill, maxFill * 100 / (size - 1));
}
@@ -50,6 +54,12 @@ void cRingBuffer::UpdatePercentage(int Fill)
lastPercent = percent;
}
}
+ if (ioThrottle) {
+ if (percent >= IOTHROTTLEHIGH)
+ ioThrottle->Activate();
+ else if (percent < IOTHROTTLELOW)
+ ioThrottle->Release();
+ }
}
void cRingBuffer::WaitForPut(void)
@@ -82,6 +92,12 @@ void cRingBuffer::SetTimeouts(int PutTimeout, int GetTimeout)
getTimeout = GetTimeout;
}
+void cRingBuffer::SetIoThrottle(void)
+{
+ if (!ioThrottle)
+ ioThrottle = new cIoThrottle;
+}
+
void cRingBuffer::ReportOverflow(int Bytes)
{
overflowCount++;