@@ -38,13 +38,11 @@ Advanced (Direct) Settings:
3838#include " ConfigAPR.h"
3939#include " Example_get_apr.h"
4040
41- int main (int argc, char **argv) {
42-
43- // input parsing
44- cmdLineOptions options;
41+ #include < future>
42+ #include < thread>
4543
46- options = read_command_line_options (argc,argv);
4744
45+ int runAPR (cmdLineOptions options) {
4846 // the apr datastructure
4947 APR<uint16_t > apr;
5048
@@ -144,10 +142,34 @@ int main(int argc, char **argv) {
144142 std::cout << " Oops, something went wrong. APR not computed :(." << std::endl;
145143 }
146144 return 0 ;
145+ }
146+
147+
148+ int main (int argc, char **argv) {
149+
150+ // input parsing
151+ cmdLineOptions options;
147152
153+ options = read_command_line_options (argc, argv);
154+ std::vector<std::future<int >> fv;
155+ fv.emplace_back (std::async (std::launch::async, [=]{ return runAPR (options); }));
156+ fv.emplace_back (std::async (std::launch::async, [=]{ return runAPR (options); }));
157+ fv.emplace_back (std::async (std::launch::async, [=]{ return runAPR (options); }));
158+ int n = 3 ;
159+ std::cout << " Waintig..." <<std::endl;
160+ for (int i = 0 ; i < fv.size ()*3 ; ++i) {
161+ fv[i % n].wait ();
162+ fv[i % n] = std::async (std::launch::async, [=]{ return runAPR (options); });
163+ }
164+
165+ for (int i = 0 ; i < fv.size (); ++i) fv[i].wait ();
166+
167+ std::cout << " DONE!" <<std::endl;
168+ return fv[0 ].get ();
148169}
149170
150171
172+
151173bool command_option_exists (char **begin, char **end, const std::string &option)
152174{
153175 return std::find (begin, end, option) != end;
0 commit comments