Skip to content

Commit

Permalink
This is a version before adding a safe ptr implementation. I forgot a
Browse files Browse the repository at this point in the history
header file so I'll do it in the next commit.
  • Loading branch information
AverageGuy committed Jul 5, 2024
1 parent e899081 commit 80c4191
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
10 changes: 5 additions & 5 deletions TaskSched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void Task::runIt() {

unsigned long Sched::getSize()
{
return tTasks.size();
return tTasks.get_size();
}
/** num = true show status of num tasks,
*
Expand All @@ -248,7 +248,7 @@ String Sched::displayStatus(int num,String taskName,bool raw) {

char temp[1000];
strcpy(temp,"");
std::list<Task*>::iterator it;
SimpleList<Task*>::iterator it;
sprintf(printBuffer,"%s","");
int cnt=0;
for (it = tTasks.begin(); it != tTasks.end(); ++it){
Expand Down Expand Up @@ -307,7 +307,7 @@ void Sched::addTask(Task *task)
#ifdef DEBUG
Serial.printf("add called for task, %s %x\n",task->getName().c_str(),task);
#endif
tTasks.push_front(task);
tTasks.push_back(task);
return;
};

Expand All @@ -329,7 +329,7 @@ void Sched::run()
#ifdef DEBUG
// Serial.println("Looking for tasks");
#endif
std::list<Task*>::iterator it;
SimpleList<Task*>::iterator it;
for (it = tTasks.begin(); it != tTasks.end(); ++it){
Task *currentTask = *it;
#ifdef DEBUGR
Expand All @@ -347,7 +347,7 @@ void Sched::run()
}
}

const std::list<Task *>& Sched::getTasks() const
const SimpleList<Task *>& Sched::getTasks() const
{
return tTasks;
}
Expand Down
11 changes: 7 additions & 4 deletions TaskSched.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

#define DEBUGA 1
#include "Arduino.h"
#include <list>
//#include <list>
#define TASK_SECOND 1000
#define TASK_MINUTE 60*TASK_SECOND

#include "SimpleList.h"


class Task;
using voidFuncTypeWith = std::function<void(Task *)>;
// was typedef std::function<void(Task *)> voidFuncTypeWith;

class InitialState {
Expand Down Expand Up @@ -192,12 +194,13 @@ Task t2(dummy, 2.0, false, 20, "On2", * false);
/** return true if the scheduler is enabled */
int isEnabled();
/** returns a list of the tasks */
const std::list<Task *>& getTasks() const;
//const std::list<Task *>& getTasks() const;
const SimpleList<Task *>& getTasks() const;
/** called perodically to check if a task should be scheduled */
void run();

private:
std::list<Task*> tTasks;
SimpleList<Task*> tTasks;
int mSchedEnabled;
};

Expand Down

0 comments on commit 80c4191

Please sign in to comment.