From 8db65a15e220b33371b1d3c502a05bf308316db4 Mon Sep 17 00:00:00 2001 From: Sascha Volkenandt Date: Thu, 4 Jan 2007 14:18:54 +0000 Subject: - added read lock objekt for channels --- pages/channels.ecpp | 26 +++++++++++++++++--------- tools.h | 15 +++++++++++++++ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/pages/channels.ecpp b/pages/channels.ecpp index 5f64d1d..02fb4a3 100644 --- a/pages/channels.ecpp +++ b/pages/channels.ecpp @@ -3,6 +3,7 @@ #include #include #include "setup.h" +#include "tools.h" using namespace vdrlive; @@ -15,17 +16,24 @@ using namespace vdrlive;
<{ - for (cChannel *channel = Channels.First(); channel && channel->Number() <= LiveSetup().GetLastChannel(); channel = Channels.Next(channel)) { - if (!channel->GroupSep() && *channel->Name()) { + ReadLock channelsLock( Channels ); + if (channelsLock) { + for (cChannel *channel = Channels.First(); channel && channel->Number() <= LiveSetup().GetLastChannel(); channel = Channels.Next(channel)) { + if (!channel->GroupSep() && *channel->Name()) { }> - + <{ - } - } - - + } + } + } else { +}> +
+ Zugriff auf Kanäle temporär nicht möglich. Bitte später versuchen. +
+<{ + } }>
diff --git a/tools.h b/tools.h index 4a01ca8..18f968d 100644 --- a/tools.h +++ b/tools.h @@ -3,11 +3,26 @@ #include #include +#include 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 -- cgit v1.2.3