I've just got finished designing my delegate system, that I've been planning on using for ISRs and scheduling.
As I'm writing my kernel in C++11, I've decided to go for a full blown implementation using variadic templates, and I'm actually quite pleased with the result, one can use it alike this;
Code: Select all
// ct = Creation Time, rt = Run Time
void function(Tuple<char,int> ct_args, Tuple<const char*> rt_args)
{
printf("%c%d%s", get<0>(ct_args), get<1>(ct_args), get<0>(rt_args));
}
Runnable<const char*>* callable1 = makeRunnable(function, 'C', -3);
callable1->invoke("PO");
And if for some reason one doesn't like the tuples, one can get rid of them using a little wrapper, using a simple tuple_concat and the unwind the tuple, this involves a wrapper of course.
Now to the question;
I'm currently using it in my scheduling (in my createThread(Runnable*) function), and I was going to use it in my ISR system too (to handle interrupts), however it has now come to my mind that maybe I should use my delegate system less, due to it's memory usage, and the overhead of the virtual function call.
The function delegate uses memory as stated below;
- * 0-1 u32int (or 0-4 u8int) arguments = 12 bytes
* 2 u32int (or 5-8 u8int) arguments = 16 bytes
So will the overhead in memory and speed end up giving me trouble, or can I just go use my system wherever I feel like it, without concern?
//Skeen