summaryrefslogtreecommitdiff
path: root/tools.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools.h')
-rw-r--r--tools.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools.h b/tools.h
index 4a01ca8..18f968d 100644
--- a/tools.h
+++ b/tools.h
@@ -3,11 +3,26 @@
#include <ctime>
#include <string>
+#include <vdr/thread.h>
namespace vdrlive {
std::string FormatDateTime( char const* format, time_t time );
+class ReadLock
+{
+public:
+ ReadLock( cRwLock& lock, int timeout = 100 ): m_lock( lock ), m_locked( false ) { if ( m_lock.Lock( false, timeout ) ) m_locked = true; }
+ ~ReadLock() { if ( m_locked ) m_lock.Unlock(); }
+
+ operator bool() { return m_locked; }
+ bool operator!() { return !m_locked; }
+
+private:
+ cRwLock& m_lock;
+ bool m_locked;
+};
+
} // namespace vdrlive
#endif // VDR_LIVE_TOOLS_H