Now that I've got something (as far as I've tested) working, I'll explain what the final system is turning out to be like.
Firstly; two reference files..
Start off in the header file.
Here you will see an interface; iThreadTest, and the implementation csThreadTest.
iThreadTest looks like a normal interface. Nothing new there.
You will see that csThreadTest implements ThreadedCallable. This is important, it basically allows the object instance of the class to be stored inside an event message. This message is what is sent to the thread manager and queued as a job to be executed by a thread.
In csThreadTest the functions you wish to be executed in other threads are declared with the THREADED_CALLABLE_DECX macro. You pass the class, the function name, the argument types and the argument names separately. This macro then does two things;
1) Creates a function called functionnameTC(). This is what your function will really be called.
2) Creates a function called functionname, to satisfy the implementation of the interface. This function will create a thread event based on the arguments passed to the macro and pass that thread event message to the thread manager for processing. It stores the arguments passed by copying them onto the heap and storing pointers to that data in an array.
Now look at the .cpp file.
The functions are implemented using the THREADED_CALLABLE_IMP macro. You again pass the class and function name, but this time you pass the argument type and name as a single argument, like you would declare a normal function.
This macro simply creates the function header for class::functionnameTC().
Go to the bottom where the main function is. See that the functions are called normally via the interface.
I will provide a more detailed look at how it works behind the scenes shortly.
|<< <||> >>|