diff options
Diffstat (limited to 'tasks.h')
-rw-r--r-- | tasks.h | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -1,6 +1,8 @@ #ifndef VDR_LIVE_TASKS_H #define VDR_LIVE_TASKS_H +#include <string> +#include <utility> #include <vdr/thread.h> namespace vdrlive { @@ -11,18 +13,40 @@ class TaskManager: public cMutex public: bool SwitchChannel( int number ); + bool ReplayRecording( std::string const& fileName ); // may only be called from Plugin::MainThreadHook void DoScheduledWork(); private: + template< typename Type > + struct Task: std::pair< Type, bool > + { + Task( Type const& first, bool second ): std::pair< Type, bool >( first, second ) {} + }; + TaskManager(); TaskManager( TaskManager const& ); - int m_switchChannel; - bool m_switchResult; + Task< int > m_switchChannel; + Task< std::string > m_replayRecording; cCondVar m_scheduleWait; + + template< typename Type > + bool ScheduleCommand( Task< Type >& member, Type const& param ); + + void DoSwitchChannel(); + void DoReplayRecording(); }; + +template< typename Type > +inline bool TaskManager::ScheduleCommand( Task< Type >& member, Type const& param ) +{ + cMutexLock lock( this ); + member.first = param; + m_scheduleWait.Wait( *this ); + return member.second; +} TaskManager& LiveTaskManager(); |