/[projects]/smsdaemon/TaskManager.cpp
ViewVC logotype

Diff of /smsdaemon/TaskManager.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 195 by torben, Wed Dec 17 12:46:49 2008 UTC revision 196 by torben, Thu Dec 18 06:53:29 2008 UTC
# Line 1  Line 1 
1            
2  #include "TaskManager.h"  #include "TaskManager.h"
3    
4  #include "Logger.h"  #include "Logger.h"
# Line 9  Line 9 
9    
10    
11  TaskManager::TaskManager()  TaskManager::TaskManager()
12   : _lastExecuted(0)                  : _lastExecuted(0)
13  {  {
14  }  }
15            
16  TaskManager::~TaskManager()  TaskManager::~TaskManager()
17  {        {
18          //delete any temporary tasks still in the list          //delete any temporary tasks still in the list
19          std::list<Task*>::iterator it;          std::list<Task*>::iterator it;
20          for (it = _temp_tasks.begin(); it != _temp_tasks.end(); ++it)          for (it = _temp_tasks.begin(); it != _temp_tasks.end(); ++it)
# Line 29  void TaskManager::LoadTasks() Line 29  void TaskManager::LoadTasks()
29          static SpoolTask task;          static SpoolTask task;
30    
31          //print the loaded tasks          //print the loaded tasks
32          std::map<std::string, Task*>::iterator it;                std::map<std::string, Task*>::iterator it;
33          for(it = _persistant_tasks.begin(); it != _persistant_tasks.end(); ++it)          for (it = _persistant_tasks.begin(); it != _persistant_tasks.end(); ++it)
34          {          {
35                  Task* tsk = (*it).second;                  Task* tsk = (*it).second;
36                  if (tsk != 0)                  if (tsk != 0)
# Line 68  void TaskManager::ExecuteTasks(ISmsTrans Line 68  void TaskManager::ExecuteTasks(ISmsTrans
68          const int SLEEP_TIME = 2; //wait this long between task executions          const int SLEEP_TIME = 2; //wait this long between task executions
69          int now = time(0);          int now = time(0);
70    
71          if (now < (_lastExecuted + SLEEP_TIME) )          if (now < (_lastExecuted + SLEEP_TIME) )
72                  return;                  return;
73    
74          _lastExecuted = now;          _lastExecuted = now;
# Line 94  void TaskManager::ExecuteTasks(ISmsTrans Line 94  void TaskManager::ExecuteTasks(ISmsTrans
94                  if ( tsk->IsFinished() )                  if ( tsk->IsFinished() )
95                  {                  {
96                          delete tsk;                          delete tsk;
97                          l_it = _temp_tasks.erase(l_it);                          l_it = _temp_tasks.erase(l_it);
98                            
99                          //now l_it points to the next element in the list,                          //now l_it points to the next element in the list,
100                          //but since the for() loop will increment it before next iteration we will decrease it here                          //but since the for() loop will increment it before next iteration we will decrease it here
101                          --l_it;                          --l_it;
102                  }                  }
103          }          }
104    

Legend:
Removed from v.195  
changed lines
  Added in v.196

  ViewVC Help
Powered by ViewVC 1.1.20