Results 1 to 2 of 2
I have a project, which need to implement a function table for multiple thread call, each thread will start with a different function, and the function table should be a ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-16-2005 #1Just Joined!
- Join Date
- Aug 2005
- Posts
- 19
how to implement a function table
I have a project, which need to implement a function table for multiple thread call, each thread will start with a different function, and the function table should be a good solution, but I can not find the good reference or programming guide for it.
Please help me out, either a sample (working sample) or an URL.
Thanks.
- 09-16-2005 #2
I normally use something like this:
It's a bit more difficult if you want the functions wrapped in a class, but it is still possible.Code:// start with a typedef for the function - all must be the same return/param types typedef int fn_declaration_type(int, int); // pre-declare the functions int entry_fn_one(int, int); int entry_fn_two(int, int); int entry_fn_three(int, int); ...etc... // declare a table fn_declaration_type fn_table[FN_TABLE_SIZE] = { entry_fn_one, entry_fn_two, entry_fn_three, ...etc... }; // implement the functions int entry_fn_one(int a, int b) { return 0; } int entry_fn_two(int a, int b) { return 0; } int entry_fn_three(int a, int b) { return 0; } ...etc...Linux user #126863 - see http://linuxcounter.net/


Reply With Quote
