summaryrefslogtreecommitdiff
path: root/tasks.cpp
diff options
context:
space:
mode:
authorSascha Volkenandt <sascha (at) akv-soft (dot) de>2007-05-04 18:53:31 +0000
committerSascha Volkenandt <sascha (at) akv-soft (dot) de>2007-05-04 18:53:31 +0000
commitf9fa26c1990e7fb7fc7f4a8f3c19175d2b5eb9c4 (patch)
treebd46c03a167be729b08f595b7c569489c4f098f9 /tasks.cpp
parent71cd02a970f6cb1844c9e94d8a8dcdb71b1bc295 (diff)
downloadvdr-plugin-live-f9fa26c1990e7fb7fc7f4a8f3c19175d2b5eb9c4.tar.gz
vdr-plugin-live-f9fa26c1990e7fb7fc7f4a8f3c19175d2b5eb9c4.tar.bz2
- moved grab task into mainthreadloop
Diffstat (limited to 'tasks.cpp')
-rw-r--r--tasks.cpp36
1 files changed, 32 insertions, 4 deletions
diff --git a/tasks.cpp b/tasks.cpp
index 5213588..0faa76f 100644
--- a/tasks.cpp
+++ b/tasks.cpp
@@ -1,3 +1,5 @@
+#include <algorithm>
+#include <boost/bind.hpp>
#include <vdr/channels.h>
#include <vdr/i18n.h>
#include <vdr/menu.h>
@@ -7,9 +9,20 @@
#include "tasks.h"
#include "tools.h"
+namespace vdrlive {
+
using namespace std;
+using namespace boost;
-namespace vdrlive {
+StickyTask::StickyTask()
+{
+ LiveTaskManager().AddStickyTask( *this );
+}
+
+StickyTask::~StickyTask()
+{
+ LiveTaskManager().RemoveStickyTask( *this );
+}
void SwitchChannelTask::Action()
{
@@ -44,6 +57,18 @@ TaskManager::TaskManager()
{
}
+void TaskManager::AddStickyTask( Task& task )
+{
+ cMutexLock lock( this );
+ m_stickyTasks.push_back( &task );
+}
+
+void TaskManager::RemoveStickyTask( Task& task )
+{
+ cMutexLock lock( this );
+ m_stickyTasks.erase( find( m_stickyTasks.begin(), m_stickyTasks.end(), &task ) );
+}
+
bool TaskManager::Execute( Task& task )
{
cMutexLock lock( this );
@@ -55,15 +80,18 @@ bool TaskManager::Execute( Task& task )
void TaskManager::DoScheduledTasks()
{
- if ( m_taskQueue.empty() )
+ if ( m_taskQueue.empty() && m_stickyTasks.empty() )
return;
cMutexLock lock( this );
- while ( !m_taskQueue.empty() ) {
+ /*while ( !m_taskQueue.empty() ) {
Task* current = m_taskQueue.front();
current->Action();
m_taskQueue.pop_front();
- }
+ }*/
+ for_each( m_taskQueue.begin(), m_taskQueue.end(), bind( &Task::Action, _1 ) );
+ for_each( m_stickyTasks.begin(), m_stickyTasks.end(), bind( &Task::Action, _1 ) );
+ m_taskQueue.clear();
m_scheduleWait.Broadcast();
}