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

Diff of /smsdaemon/TaskManager.cpp

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

revision 81 by torben, Mon Jun 9 18:15:53 2008 UTC revision 82 by torben, Sun Jun 15 20:06:39 2008 UTC
# Line 3  Line 3 
3    
4  #include "common.h"  #include "common.h"
5    
6    #include <time.h>
7    
8  TaskManager::TaskManager()  TaskManager::TaskManager()
9     : _lastExecuted(0)
10  {  {
11  }  }
12                    
# Line 19  void TaskManager::LoadTasks() Line 20  void TaskManager::LoadTasks()
20    
21  }  }
22    
23    
24    void TaskManager::ExecuteTasks()
25    {
26            int now = time(0);
27    
28            if (now > _lastExecuted) // only execute the tasks once every second
29            {
30                    _lastExecuted = now;
31    
32                    std::map<std::string, Task*>::iterator it;
33    
34                    for (it = _tasks.begin(); it != _tasks.end(); ++it)
35                    {
36                            Task* tsk = (*it).second;
37                            tsk->ExecuteTask();
38                    }
39            }
40    }
41    
42    
43  Task* TaskManager::GetTask(const std::string& taskname)  Task* TaskManager::GetTask(const std::string& taskname)
44  {  {
45          return _tasks[ taskname ];          return _tasks[ taskname ];
# Line 30  std::vector<Task*> TaskManager::GetTaskL Line 51  std::vector<Task*> TaskManager::GetTaskL
51          typedef std::map<std::string, Task*>::iterator MapIterator;          typedef std::map<std::string, Task*>::iterator MapIterator;
52          std::vector<Task*> task_list;          std::vector<Task*> task_list;
53    
54          for (MapIterator it = _tasks.begin(); it != _tasks.end(); it++)          for (MapIterator it = _tasks.begin(); it != _tasks.end(); ++it)
55          {          {
56                  Task* pl = (*it).second;                  Task* pl = (*it).second;
57                  task_list.push_back(pl);                  task_list.push_back(pl);

Legend:
Removed from v.81  
changed lines
  Added in v.82

  ViewVC Help
Powered by ViewVC 1.1.20