Last active
October 18, 2016 15:03
-
-
Save jacknlliu/4c8db7c64e2501941a07007ff2f60271 to your computer and use it in GitHub Desktop.
A framework for programs with event loop handler and thread like Qt main() function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // some global data for share | |
| data global_for_share; | |
| // define class class_main for all tasks | |
| class class_main | |
| { | |
| public: | |
| class_main(data* shared_data){ | |
| // setup (software/hardware)interrupt/callback in class_main constructor function or its member function | |
| // setup thread in class_main constructor function or its member function | |
| } | |
| // setup shared data(data member) in class_main | |
| data* data_member; | |
| } | |
| int main(int argc, char const *argv[]) { | |
| data input_shared_data; | |
| // create the main object to represent all tasks inside | |
| class_main main_object(input_shared_data); // or use global data as input | |
| /* | |
| * setup a system call/system message mechanism for event loop, | |
| * and receive outside input to trigger callback function of the main_object instance | |
| * to drive the main_object instance. | |
| */ | |
| exec(); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment