Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <shogun/base/init.h>
- #include <shogun/lib/Signal.h>
- #include <shogun/machine/Machine.h>
- #include <iostream>
- #include <thread>
- using namespace shogun;
- using namespace std;
- class MockAlg : public CMachine {
- public:
- MockAlg() {}
- ~MockAlg() {}
- void loop() {
- #pragma omp parallel for
- for (int i=0; i<1000; i++)
- {
- if (cancel_computation())
- continue;
- cout << i << endl;
- this_thread::sleep_for(chrono::milliseconds(1000));
- }
- }
- };
- int main() {
- init_shogun_with_defaults();
- // Enable the signal handler
- get_global_signal()->enable_handler();
- MockAlg a;
- a.connect_to_signal_handler();
- MockAlg b;
- cout << "RUN FIRST TEST" << endl;
- a.loop();
- cout << "RUN SECOND TEST" << endl;
- b.connect_to_signal_handler();
- b.loop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement