1 |
|
|
2 |
#include "TaskManager.h" |
#include "TaskManager.h" |
3 |
|
|
4 |
#include "Logger.h" |
#include "Logger.h" |
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) |
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) |
65 |
|
|
66 |
void TaskManager::ExecuteTasks(ISmsTransceiver& modem) |
void TaskManager::ExecuteTasks(ISmsTransceiver& modem) |
67 |
{ |
{ |
68 |
const int SLEEP_TIME = 10; //wait at least 10 seconds between 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; |
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 |
|
|