Close

ANTIRTOS v0.2.0: An Ultralightweight Easy To Use Multitasking C++ Lib. Simplified Examples Of Use

aleksei-tertychnyiAleksei Tertychnyi wrote 07/22/2024 at 13:06 • 2 min read • Like

fQ is a class for creation simple queue of procedures (functions  getting and returning void).
An example:

#include <antirtos.h>
void task1(void){   // some procedure
  //do something
}
void task2(void){   // some procedure
  //do something
}
fQ queue1(8); // create a FIFO queue of 8 pointers length
queue1.push(task1); // anywhere, for example example in some interrupt
queue1.push(task2); // for example in the same interrupt
//.....
queue1.pull();  // in the main loop


fQP is a class for creation queue of functions receiving parameter, it may be your own class with fixed size, like structure or standard one.
An example:

uint32_t somevalue1 = 123456;  //value to call task1 with
uint32_t somevalue2 = 789012; // /value to call task1 with

void task1(uint32_t){   // some function with parameter
  //do something
}
void task2(uint32_t){   // some function with parameter
  //do something
}
fQP<uint32_t> queue2(4); // create a FIFO queue of 4 pointers length for functions returning void, and receiving uint32_t parameter

queue2.push(task1, somevalue1); // anywhere, for example example in some interrupt
queue2.push(task2, somevalue2); // for example in the same interrupt
//.....
queue2.pull();  // in the main loop

del_fQ is a class for creating simple queue of procedures (functions  getting and returning void) but delayed for some 'ticks'.
An example:

void task1(void){   // some procedure
  //do something
}
void task2(void){   // some procedure
  //do something
}
del_fQ queue3(8); // create a 'delayed'  FIFO queue of 8 pointers length for functions returning void, and receiving void

queue3.push(task1, 123); // anywhere, for example example in some interrupt, this task will be delayed for delay1 ticks from here 
                         // this delay const or variable of type unsigned int 
queue3.push(task2, 344); // for example in the same interrupt, this task will be delayed for delay2 ticks from here
                         //  this delay const or variable of type unsigned int 
//.....
queue3.pull();  // in the main loop

//...
queue3.tick();  //in same periodic function, it maybe for example some timer elapsed interrupt, or even main loop
Like

Discussions