summaryrefslogtreecommitdiff
path: root/thread.h
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 /thread.h
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 'thread.h')
-rw-r--r--thread.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/thread.h b/thread.h
index d4919eb6..f77e8198 100644
--- a/thread.h
+++ b/thread.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: thread.h 2.1 2009/04/13 13:50:39 kls Exp $
+ * $Id: thread.h 2.2 2012/09/20 08:46:27 kls Exp $
*/
#ifndef __THREAD_H
@@ -157,6 +157,29 @@ public:
#define LOCK_THREAD cThreadLock ThreadLock(this)
+class cIoThrottle {
+private:
+ static cMutex mutex;
+ static int count;
+ bool active;
+public:
+ cIoThrottle(void);
+ ~cIoThrottle();
+ void Activate(void);
+ ///< Activates the global I/O throttling mechanism.
+ ///< This function may be called any number of times, but only
+ ///< the first call after an inactive state will have an effect.
+ void Release(void);
+ ///< Releases the global I/O throttling mechanism.
+ ///< This function may be called any number of times, but only
+ ///< the first call after an active state will have an effect.
+ bool Active(void) { return active; }
+ ///< Returns true if this I/O throttling object is currently active.
+ static bool Engaged(void);
+ ///< Returns true if any I/O throttling object is currently active.
+ };
+
+
// cPipe implements a pipe that closes all unnecessary file descriptors in
// the child process.