int main(){ function1(); function2(); return 0; }
int main() { function2 f2; const function2 cf2; function3 f3; handler2 h2; const handler2 ch2; handler3 h3; std::experimental::loop_scheduler scheduler; std::experimental::executor ex = scheduler.get_executor(); ex = std::experimental::system_executor(); assert(&ex.context() == &std::experimental::system_executor().context()); invoke(std::experimental::chain(ex.wrap(function1))); invoke(std::experimental::chain(ex.wrap(function1), handler1)); invoke(std::experimental::chain(ex.wrap(function1), &handler1)); invoke(std::experimental::chain(ex.wrap(function1), handler2())); invoke(std::experimental::chain(ex.wrap(function1), h2)); invoke(std::experimental::chain(ex.wrap(function1), ch2)); invoke(std::experimental::chain(ex.wrap(function1), handler3())); invoke(std::experimental::chain(ex.wrap(function1), std::move(h3))); invoke(std::experimental::chain(ex.wrap(&function1))); invoke(std::experimental::chain(ex.wrap(&function1), handler1)); invoke(std::experimental::chain(ex.wrap(&function1), &handler1)); invoke(std::experimental::chain(ex.wrap(&function1), handler2())); invoke(std::experimental::chain(ex.wrap(&function1), h2)); invoke(std::experimental::chain(ex.wrap(&function1), ch2)); invoke(std::experimental::chain(ex.wrap(&function1), handler3())); invoke(std::experimental::chain(ex.wrap(&function1), std::move(h3))); invoke(std::experimental::chain(ex.wrap(function2()))); invoke(std::experimental::chain(ex.wrap(function2()), handler1)); invoke(std::experimental::chain(ex.wrap(function2()), &handler1)); invoke(std::experimental::chain(ex.wrap(function2()), handler2())); invoke(std::experimental::chain(ex.wrap(function2()), h2)); invoke(std::experimental::chain(ex.wrap(function2()), ch2)); invoke(std::experimental::chain(ex.wrap(function2()), handler3())); invoke(std::experimental::chain(ex.wrap(function2()), std::move(h3))); invoke(std::experimental::chain(ex.wrap(f2))); invoke(std::experimental::chain(ex.wrap(f2), handler1)); invoke(std::experimental::chain(ex.wrap(f2), &handler1)); invoke(std::experimental::chain(ex.wrap(f2), handler2())); invoke(std::experimental::chain(ex.wrap(f2), h2)); invoke(std::experimental::chain(ex.wrap(f2), ch2)); invoke(std::experimental::chain(ex.wrap(f2), handler3())); invoke(std::experimental::chain(ex.wrap(f2), std::move(h3))); invoke(std::experimental::chain(ex.wrap(cf2))); invoke(std::experimental::chain(ex.wrap(cf2), handler1)); invoke(std::experimental::chain(ex.wrap(cf2), &handler1)); invoke(std::experimental::chain(ex.wrap(cf2), handler2())); invoke(std::experimental::chain(ex.wrap(cf2), h2)); invoke(std::experimental::chain(ex.wrap(cf2), ch2)); invoke(std::experimental::chain(ex.wrap(cf2), handler3())); invoke(std::experimental::chain(ex.wrap(cf2), std::move(h3))); invoke(std::experimental::chain(ex.wrap(function3()))); invoke(std::experimental::chain(ex.wrap(function3()), handler1)); invoke(std::experimental::chain(ex.wrap(function3()), &handler1)); invoke(std::experimental::chain(ex.wrap(function3()), handler2())); invoke(std::experimental::chain(ex.wrap(function3()), h2)); invoke(std::experimental::chain(ex.wrap(function3()), ch2)); invoke(std::experimental::chain(ex.wrap(function3()), handler3())); invoke(std::experimental::chain(ex.wrap(function3()), std::move(h3))); invoke(std::experimental::chain(ex.wrap(std::move(f3)))); invoke(std::experimental::chain(ex.wrap(std::move(f3)), handler1)); invoke(std::experimental::chain(ex.wrap(std::move(f3)), &handler1)); invoke(std::experimental::chain(ex.wrap(std::move(f3)), handler2())); invoke(std::experimental::chain(ex.wrap(std::move(f3)), h2)); invoke(std::experimental::chain(ex.wrap(std::move(f3)), ch2)); invoke(std::experimental::chain(ex.wrap(std::move(f3)), handler3())); invoke(std::experimental::chain(ex.wrap(std::move(f3)), std::move(h3))); assert(function_count == 56); assert(handler_count == 49); }
int main() { function2 f2; const function2 cf2; function3 f3; handler2 h2; const handler2 ch2; handler3 h3; std::experimental::thread_pool pool; auto ex = make_executor(pool); std::experimental::dispatch(ex, function1, handler1); std::experimental::dispatch(ex, function1, &handler1); std::experimental::dispatch(ex, function1, handler2()); std::experimental::dispatch(ex, function1, h2); std::experimental::dispatch(ex, function1, ch2); std::experimental::dispatch(ex, function1, handler3()); std::experimental::dispatch(ex, function1, std::move(h3)); std::future<int> fut1 = std::experimental::dispatch(ex, function1, std::experimental::use_future); fut1.get(); std::experimental::dispatch(ex, &function1, handler1); std::experimental::dispatch(ex, &function1, &handler1); std::experimental::dispatch(ex, &function1, handler2()); std::experimental::dispatch(ex, &function1, h2); std::experimental::dispatch(ex, &function1, ch2); std::experimental::dispatch(ex, &function1, handler3()); std::experimental::dispatch(ex, &function1, std::move(h3)); std::future<int> fut2 = std::experimental::dispatch(ex, &function1, std::experimental::use_future); fut2.get(); std::experimental::dispatch(ex, function2(), handler1); std::experimental::dispatch(ex, function2(), &handler1); std::experimental::dispatch(ex, function2(), handler2()); std::experimental::dispatch(ex, function2(), h2); std::experimental::dispatch(ex, function2(), ch2); std::experimental::dispatch(ex, function2(), handler3()); std::experimental::dispatch(ex, function2(), std::move(h3)); std::future<int> fut3 = std::experimental::dispatch(ex, function2(), std::experimental::use_future); fut3.get(); std::experimental::dispatch(ex, f2, handler1); std::experimental::dispatch(ex, f2, &handler1); std::experimental::dispatch(ex, f2, handler2()); std::experimental::dispatch(ex, f2, h2); std::experimental::dispatch(ex, f2, ch2); std::experimental::dispatch(ex, f2, handler3()); std::experimental::dispatch(ex, f2, std::move(h3)); std::future<int> fut4 = std::experimental::dispatch(ex, f2, std::experimental::use_future); fut4.get(); std::experimental::dispatch(ex, cf2, handler1); std::experimental::dispatch(ex, cf2, &handler1); std::experimental::dispatch(ex, cf2, handler2()); std::experimental::dispatch(ex, cf2, h2); std::experimental::dispatch(ex, cf2, ch2); std::experimental::dispatch(ex, cf2, handler3()); std::experimental::dispatch(ex, cf2, std::move(h3)); std::future<int> fut5 = std::experimental::dispatch(ex, cf2, std::experimental::use_future); fut5.get(); std::experimental::dispatch(ex, function3(), handler1); std::experimental::dispatch(ex, function3(), &handler1); std::experimental::dispatch(ex, function3(), handler2()); std::experimental::dispatch(ex, function3(), h2); std::experimental::dispatch(ex, function3(), ch2); std::experimental::dispatch(ex, function3(), handler3()); std::experimental::dispatch(ex, function3(), std::move(h3)); std::future<int> fut6 = std::experimental::dispatch(ex, function3(), std::experimental::use_future); fut6.get(); std::experimental::dispatch(ex, std::move(f3), handler1); std::experimental::dispatch(ex, std::move(f3), &handler1); std::experimental::dispatch(ex, std::move(f3), handler2()); std::experimental::dispatch(ex, std::move(f3), h2); std::experimental::dispatch(ex, std::move(f3), ch2); std::experimental::dispatch(ex, std::move(f3), handler3()); std::experimental::dispatch(ex, std::move(f3), std::move(h3)); std::future<int> fut7 = std::experimental::dispatch(ex, std::move(f3), std::experimental::use_future); fut7.get(); pool.join(); assert(function_count == 56); assert(handler_count == 49); }
int main() { function2 f2; const function2 cf2; function3 f3; handler2 h2; const handler2 ch2; handler3 h3; std::experimental::loop_scheduler scheduler; std::experimental::executor ex = make_executor(scheduler); ex = std::experimental::system_executor(); assert(&ex.context() == &std::experimental::system_executor().context()); auto abs_time = std::chrono::steady_clock::now() + std::chrono::milliseconds(100); std::experimental::dispatch_at(abs_time, ex, function1, handler1); std::experimental::dispatch_at(abs_time, ex, function1, &handler1); std::experimental::dispatch_at(abs_time, ex, function1, handler2()); std::experimental::dispatch_at(abs_time, ex, function1, h2); std::experimental::dispatch_at(abs_time, ex, function1, ch2); std::experimental::dispatch_at(abs_time, ex, function1, handler3()); std::experimental::dispatch_at(abs_time, ex, function1, std::move(h3)); std::future<void> fut1 = std::experimental::dispatch_at(abs_time, ex, function1, std::experimental::use_future); fut1.get(); std::experimental::dispatch_at(abs_time, ex, &function1, handler1); std::experimental::dispatch_at(abs_time, ex, &function1, &handler1); std::experimental::dispatch_at(abs_time, ex, &function1, handler2()); std::experimental::dispatch_at(abs_time, ex, &function1, h2); std::experimental::dispatch_at(abs_time, ex, &function1, ch2); std::experimental::dispatch_at(abs_time, ex, &function1, handler3()); std::experimental::dispatch_at(abs_time, ex, &function1, std::move(h3)); std::future<void> fut2 = std::experimental::dispatch_at(abs_time, ex, &function1, std::experimental::use_future); fut2.get(); std::experimental::dispatch_at(abs_time, ex, function2(), handler1); std::experimental::dispatch_at(abs_time, ex, function2(), &handler1); std::experimental::dispatch_at(abs_time, ex, function2(), handler2()); std::experimental::dispatch_at(abs_time, ex, function2(), h2); std::experimental::dispatch_at(abs_time, ex, function2(), ch2); std::experimental::dispatch_at(abs_time, ex, function2(), handler3()); std::experimental::dispatch_at(abs_time, ex, function2(), std::move(h3)); std::future<void> fut3 = std::experimental::dispatch_at(abs_time, ex, function2(), std::experimental::use_future); fut3.get(); std::experimental::dispatch_at(abs_time, ex, f2, handler1); std::experimental::dispatch_at(abs_time, ex, f2, &handler1); std::experimental::dispatch_at(abs_time, ex, f2, handler2()); std::experimental::dispatch_at(abs_time, ex, f2, h2); std::experimental::dispatch_at(abs_time, ex, f2, ch2); std::experimental::dispatch_at(abs_time, ex, f2, handler3()); std::experimental::dispatch_at(abs_time, ex, f2, std::move(h3)); std::future<void> fut4 = std::experimental::dispatch_at(abs_time, ex, f2, std::experimental::use_future); fut4.get(); std::experimental::dispatch_at(abs_time, ex, cf2, handler1); std::experimental::dispatch_at(abs_time, ex, cf2, &handler1); std::experimental::dispatch_at(abs_time, ex, cf2, handler2()); std::experimental::dispatch_at(abs_time, ex, cf2, h2); std::experimental::dispatch_at(abs_time, ex, cf2, ch2); std::experimental::dispatch_at(abs_time, ex, cf2, handler3()); std::experimental::dispatch_at(abs_time, ex, cf2, std::move(h3)); std::future<void> fut5 = std::experimental::dispatch_at(abs_time, ex, cf2, std::experimental::use_future); fut5.get(); std::experimental::dispatch_at(abs_time, ex, function3(), handler1); std::experimental::dispatch_at(abs_time, ex, function3(), &handler1); std::experimental::dispatch_at(abs_time, ex, function3(), handler2()); std::experimental::dispatch_at(abs_time, ex, function3(), h2); std::experimental::dispatch_at(abs_time, ex, function3(), ch2); std::experimental::dispatch_at(abs_time, ex, function3(), handler3()); std::experimental::dispatch_at(abs_time, ex, function3(), std::move(h3)); std::future<void> fut6 = std::experimental::dispatch_at(abs_time, ex, function3(), std::experimental::use_future); fut6.get(); std::experimental::dispatch_at(abs_time, ex, std::move(f3), handler1); std::experimental::dispatch_at(abs_time, ex, std::move(f3), &handler1); std::experimental::dispatch_at(abs_time, ex, std::move(f3), handler2()); std::experimental::dispatch_at(abs_time, ex, std::move(f3), h2); std::experimental::dispatch_at(abs_time, ex, std::move(f3), ch2); std::experimental::dispatch_at(abs_time, ex, std::move(f3), handler3()); std::experimental::dispatch_at(abs_time, ex, std::move(f3), std::move(h3)); std::future<void> fut7 = std::experimental::dispatch_at(abs_time, ex, std::move(f3), std::experimental::use_future); fut7.get(); std::this_thread::sleep_for(std::chrono::seconds(1)); assert(function_count == 56); assert(handler_count == 49); }
int main(int argc, char **argv) { //SCENARIO 0 //Passing a primitive by value. arg0 should NOT be put on the heap. int arg0 = 32; arg0 = function2(arg0); //SCENARIO 1 //Passing a local via address. arg1 should be put on the heap. int arg1 = 7; function1(&arg1); //SCENARIO 2 //Passing a pointer to a local variable. arg2 should be put on the heap. arg3 should NOT. int arg2 = 4; int *arg3 = &arg2; function1(arg3); //SCENARIO 3 //Passing a pointer to a heap address. arg4 should NOT be put on the heap. int * arg4 = (int *) malloc(sizeof(int)); (*arg4) = 3; function1(arg4); //SCENARIO 4 //Passing a pointer to a heap address that turns into a local address. arg6 should be put on the heap. //arg5 should NOT. int * arg5 = (int *) malloc(sizeof(int)); (*arg5) = 56; int arg6 = 5; arg5 = &arg6; function1(arg5); //SCENARIO 5 //Passing a pointer by address that points to dynamically allocated memory. arg7 should be put on the heap. int * arg7 = (int *) malloc(sizeof(int)); function3(&arg7); //SCENARIO 6 //Passing a pointer that points to a pointer to a pointer. //arg9 and 8 should be put on the heap. arg10 should NOT. int arg8 = 34; int * arg9 = &arg8; int ** arg10 = &arg9; function3(arg10); //SCENARIO 7 //Passing a pointer that points to a pointer to a malloc. //arg11 should be placed on the heap. int * arg11 = (int *) malloc(sizeof(int)); int ** arg12 = &arg11; function3(arg12); //SCENARIO 8 //Passing a pointer that points to a value onto the heap. //arg13 and arg14 should be placed on the heap. int arg13 = 35; int * arg14 = &arg13; function3(&arg14); //SCENARIO 9 //Passing a pointer to the address of a local stored in an intermediate value. //Only arg15 should be put on the heap. int arg15 = 34; int * arg16 = &arg15; int ** arg17 = (int **) malloc(sizeof(int*)); (*arg17) = arg16; function3(arg17); int arg18 = 34; //PHI: Simple conditional. //arg18 should be placed in the heap. if (arg15 > 10) { function1(&arg18); } else { arg18 *= 2; } int count = 0; for (count = 0; count < arg18; count++) { int blahblah = 34; blahblah *= arg15; printf("%d\n", blahblah); arg15 += 34; } return 0; }
int main() { function2 f2; const function2 cf2; function3 f3; handler2 h2; const handler2 ch2; handler3 h3; std::experimental::loop_scheduler scheduler; auto ex = make_strand(scheduler.get_executor()); std::experimental::executor_work<decltype(ex)> w(ex); std::thread t([&](){ scheduler.run(); }); std::experimental::post(ex, function1, handler1); std::experimental::post(ex, function1, &handler1); std::experimental::post(ex, function1, handler2()); std::experimental::post(ex, function1, h2); std::experimental::post(ex, function1, ch2); std::experimental::post(ex, function1, handler3()); std::experimental::post(ex, function1, std::move(h3)); std::future<int> fut1 = std::experimental::post(ex, function1, std::experimental::use_future); fut1.get(); std::experimental::post(ex, &function1, handler1); std::experimental::post(ex, &function1, &handler1); std::experimental::post(ex, &function1, handler2()); std::experimental::post(ex, &function1, h2); std::experimental::post(ex, &function1, ch2); std::experimental::post(ex, &function1, handler3()); std::experimental::post(ex, &function1, std::move(h3)); std::future<int> fut2 = std::experimental::post(ex, &function1, std::experimental::use_future); fut2.get(); std::experimental::post(ex, function2(), handler1); std::experimental::post(ex, function2(), &handler1); std::experimental::post(ex, function2(), handler2()); std::experimental::post(ex, function2(), h2); std::experimental::post(ex, function2(), ch2); std::experimental::post(ex, function2(), handler3()); std::experimental::post(ex, function2(), std::move(h3)); std::future<int> fut3 = std::experimental::post(ex, function2(), std::experimental::use_future); fut3.get(); std::experimental::post(ex, f2, handler1); std::experimental::post(ex, f2, &handler1); std::experimental::post(ex, f2, handler2()); std::experimental::post(ex, f2, h2); std::experimental::post(ex, f2, ch2); std::experimental::post(ex, f2, handler3()); std::experimental::post(ex, f2, std::move(h3)); std::future<int> fut4 = std::experimental::post(ex, f2, std::experimental::use_future); fut4.get(); std::experimental::post(ex, cf2, handler1); std::experimental::post(ex, cf2, &handler1); std::experimental::post(ex, cf2, handler2()); std::experimental::post(ex, cf2, h2); std::experimental::post(ex, cf2, ch2); std::experimental::post(ex, cf2, handler3()); std::experimental::post(ex, cf2, std::move(h3)); std::future<int> fut5 = std::experimental::post(ex, cf2, std::experimental::use_future); fut5.get(); std::experimental::post(ex, function3(), handler1); std::experimental::post(ex, function3(), &handler1); std::experimental::post(ex, function3(), handler2()); std::experimental::post(ex, function3(), h2); std::experimental::post(ex, function3(), ch2); std::experimental::post(ex, function3(), handler3()); std::experimental::post(ex, function3(), std::move(h3)); std::future<int> fut6 = std::experimental::post(ex, function3(), std::experimental::use_future); fut6.get(); std::experimental::post(ex, std::move(f3), handler1); std::experimental::post(ex, std::move(f3), &handler1); std::experimental::post(ex, std::move(f3), handler2()); std::experimental::post(ex, std::move(f3), h2); std::experimental::post(ex, std::move(f3), ch2); std::experimental::post(ex, std::move(f3), handler3()); std::experimental::post(ex, std::move(f3), std::move(h3)); std::future<int> fut7 = std::experimental::post(ex, std::move(f3), std::experimental::use_future); fut7.get(); w.reset(); t.join(); assert(function_count == 56); assert(handler_count == 49); }
/* define global vars */ int a, b; int simple; printf( "\n" ); a = random(); printf( "\tToday's randum number is %d \n", a); /* assign return val to global var */ b = function1(); printf( "\tCalled function1 \n" ); /* assign return val to global var */ simple = function2(a,1); printf( "\tAdding 1 to our random number gives %d \n", simple ); printf( "\n" ); } int function1 () { /* do nothing */ } int function2 (a, b) {
int main() { function2 f2; const function2 cf2; function3 f3; handler2 h2; const handler2 ch2; handler3 h3; std::experimental::post(function1); std::experimental::post(function1, handler1); std::experimental::post(function1, &handler1); std::experimental::post(function1, handler2()); std::experimental::post(function1, h2); std::experimental::post(function1, ch2); std::experimental::post(function1, handler3()); std::experimental::post(function1, std::move(h3)); std::future<int> fut1 = std::experimental::post(function1, std::experimental::use_future); fut1.get(); std::experimental::post(&function1); std::experimental::post(&function1, handler1); std::experimental::post(&function1, &handler1); std::experimental::post(&function1, handler2()); std::experimental::post(&function1, h2); std::experimental::post(&function1, ch2); std::experimental::post(&function1, handler3()); std::experimental::post(&function1, std::move(h3)); std::future<int> fut2 = std::experimental::post(&function1, std::experimental::use_future); fut2.get(); std::experimental::post(function2()); std::experimental::post(function2(), handler1); std::experimental::post(function2(), &handler1); std::experimental::post(function2(), handler2()); std::experimental::post(function2(), h2); std::experimental::post(function2(), ch2); std::experimental::post(function2(), handler3()); std::experimental::post(function2(), std::move(h3)); std::future<int> fut3 = std::experimental::post(function2(), std::experimental::use_future); fut3.get(); std::experimental::post(f2); std::experimental::post(f2, handler1); std::experimental::post(f2, &handler1); std::experimental::post(f2, handler2()); std::experimental::post(f2, h2); std::experimental::post(f2, ch2); std::experimental::post(f2, handler3()); std::experimental::post(f2, std::move(h3)); std::future<int> fut4 = std::experimental::post(f2, std::experimental::use_future); fut4.get(); std::experimental::post(cf2); std::experimental::post(cf2, handler1); std::experimental::post(cf2, &handler1); std::experimental::post(cf2, handler2()); std::experimental::post(cf2, h2); std::experimental::post(cf2, ch2); std::experimental::post(cf2, handler3()); std::experimental::post(cf2, std::move(h3)); std::future<int> fut5 = std::experimental::post(cf2, std::experimental::use_future); fut5.get(); std::experimental::post(function3()); std::experimental::post(function3(), handler1); std::experimental::post(function3(), &handler1); std::experimental::post(function3(), handler2()); std::experimental::post(function3(), h2); std::experimental::post(function3(), ch2); std::experimental::post(function3(), handler3()); std::experimental::post(function3(), std::move(h3)); std::future<int> fut6 = std::experimental::post(function3(), std::experimental::use_future); fut6.get(); std::experimental::post(std::move(f3)); std::experimental::post(std::move(f3), handler1); std::experimental::post(std::move(f3), &handler1); std::experimental::post(std::move(f3), handler2()); std::experimental::post(std::move(f3), h2); std::experimental::post(std::move(f3), ch2); std::experimental::post(std::move(f3), handler3()); std::experimental::post(std::move(f3), std::move(h3)); std::future<int> fut7 = std::experimental::post(std::move(f3), std::experimental::use_future); fut7.get(); std::this_thread::sleep_for(std::chrono::seconds(1)); assert(function_count == 63); assert(handler_count == 49); std::future<int> fut8 = std::experimental::post(function_throw, std::experimental::use_future); try { fut8.get(); assert(0); } catch (std::exception& e) { assert(e.what() == std::string("oops")); } std::future<int> fut9 = std::experimental::post(std::experimental::package(function_throw)); try { fut9.get(); assert(0); } catch (std::exception& e) { assert(e.what() == std::string("oops")); } }
int main() { function2 f2; const function2 cf2; function3 f3; handler2 h2; const handler2 ch2; handler3 h3; std::experimental::thread_pool pool; std::experimental::post(std::experimental::wrap(pool, function1), handler1); std::experimental::post(std::experimental::wrap(pool, function1), &handler1); std::experimental::post(std::experimental::wrap(pool, function1), handler2()); std::experimental::post(std::experimental::wrap(pool, function1), h2); std::experimental::post(std::experimental::wrap(pool, function1), ch2); std::experimental::post(std::experimental::wrap(pool, function1), handler3()); std::experimental::post(std::experimental::wrap(pool, function1), std::move(h3)); std::future<void> fut1 = std::experimental::post(std::experimental::wrap(pool, function1), std::experimental::use_future); fut1.get(); std::experimental::post(std::experimental::wrap(pool, &function1), handler1); std::experimental::post(std::experimental::wrap(pool, &function1), &handler1); std::experimental::post(std::experimental::wrap(pool, &function1), handler2()); std::experimental::post(std::experimental::wrap(pool, &function1), h2); std::experimental::post(std::experimental::wrap(pool, &function1), ch2); std::experimental::post(std::experimental::wrap(pool, &function1), handler3()); std::experimental::post(std::experimental::wrap(pool, &function1), std::move(h3)); std::future<void> fut2 = std::experimental::post(std::experimental::wrap(pool, &function1), std::experimental::use_future); fut2.get(); std::experimental::post(std::experimental::wrap(pool, function2()), handler1); std::experimental::post(std::experimental::wrap(pool, function2()), &handler1); std::experimental::post(std::experimental::wrap(pool, function2()), handler2()); std::experimental::post(std::experimental::wrap(pool, function2()), h2); std::experimental::post(std::experimental::wrap(pool, function2()), ch2); std::experimental::post(std::experimental::wrap(pool, function2()), handler3()); std::experimental::post(std::experimental::wrap(pool, function2()), std::move(h3)); std::future<void> fut3 = std::experimental::post(std::experimental::wrap(pool, function2()), std::experimental::use_future); fut3.get(); std::experimental::post(std::experimental::wrap(pool, f2), handler1); std::experimental::post(std::experimental::wrap(pool, f2), &handler1); std::experimental::post(std::experimental::wrap(pool, f2), handler2()); std::experimental::post(std::experimental::wrap(pool, f2), h2); std::experimental::post(std::experimental::wrap(pool, f2), ch2); std::experimental::post(std::experimental::wrap(pool, f2), handler3()); std::experimental::post(std::experimental::wrap(pool, f2), std::move(h3)); std::future<void> fut4 = std::experimental::post(std::experimental::wrap(pool, f2), std::experimental::use_future); fut4.get(); std::experimental::post(std::experimental::wrap(pool, cf2), handler1); std::experimental::post(std::experimental::wrap(pool, cf2), &handler1); std::experimental::post(std::experimental::wrap(pool, cf2), handler2()); std::experimental::post(std::experimental::wrap(pool, cf2), h2); std::experimental::post(std::experimental::wrap(pool, cf2), ch2); std::experimental::post(std::experimental::wrap(pool, cf2), handler3()); std::experimental::post(std::experimental::wrap(pool, cf2), std::move(h3)); std::future<void> fut5 = std::experimental::post(std::experimental::wrap(pool, cf2), std::experimental::use_future); fut5.get(); std::experimental::post(std::experimental::wrap(pool, function3()), handler1); std::experimental::post(std::experimental::wrap(pool, function3()), &handler1); std::experimental::post(std::experimental::wrap(pool, function3()), handler2()); std::experimental::post(std::experimental::wrap(pool, function3()), h2); std::experimental::post(std::experimental::wrap(pool, function3()), ch2); std::experimental::post(std::experimental::wrap(pool, function3()), handler3()); std::experimental::post(std::experimental::wrap(pool, function3()), std::move(h3)); std::future<void> fut6 = std::experimental::post(std::experimental::wrap(pool, function3()), std::experimental::use_future); fut6.get(); std::experimental::post(std::experimental::wrap(pool, std::move(f3)), handler1); std::experimental::post(std::experimental::wrap(pool, std::move(f3)), &handler1); std::experimental::post(std::experimental::wrap(pool, std::move(f3)), handler2()); std::experimental::post(std::experimental::wrap(pool, std::move(f3)), h2); std::experimental::post(std::experimental::wrap(pool, std::move(f3)), ch2); std::experimental::post(std::experimental::wrap(pool, std::move(f3)), handler3()); std::experimental::post(std::experimental::wrap(pool, std::move(f3)), std::move(h3)); std::future<void> fut7 = std::experimental::post(std::experimental::wrap(pool, std::move(f3)), std::experimental::use_future); fut7.get(); pool.join(); assert(function_count == 56); assert(handler_count == 49); }
/** Cache J2000 rotation over existing cached time range using polynomials * * This method will reload an internal cache with matrices * formed from rotation angles fit to polynomials over a time * range. * * @param function1 The first polynomial function used to * find the rotation angles * @param function2 The second polynomial function used to * find the rotation angles * @param function3 The third polynomial function used to * find the rotation angles */ void LineScanCameraRotation::ReloadCache() { NaifStatus::CheckErrors(); // Make sure caches are already loaded if(!p_cachesLoaded) { QString msg = "A LineScanCameraRotation cache has not been loaded yet"; throw IException(IException::Programmer, msg, _FILEINFO_); } // Clear existing matrices from cache p_cache.clear(); // Create polynomials fit to angles & use to reload cache Isis::PolynomialUnivariate function1(p_degree); Isis::PolynomialUnivariate function2(p_degree); Isis::PolynomialUnivariate function3(p_degree); // Get the coefficients of the polynomials already fit to the angles of rotation defining [CI] std::vector<double> coeffAng1; std::vector<double> coeffAng2; std::vector<double> coeffAng3; GetPolynomial(coeffAng1, coeffAng2, coeffAng3); // Reset linear term to center around zero -- what works best is either roll-avg & pitchavg+ or pitchavg+ & yawavg- // coeffAng1[1] -= 0.0000158661225; // coeffAng2[1] = 0.0000308433; // coeffAng3[0] = -0.001517547; if(p_pitchRate) coeffAng2[1] = p_pitchRate; if(p_yaw) coeffAng3[0] = p_yaw; // Load the functions with the coefficients function1.SetCoefficients(coeffAng1); function2.SetCoefficients(coeffAng2); function3.SetCoefficients(coeffAng3); double CI[3][3]; double IJ[3][3]; std::vector<double> rtime; SpiceRotation *prot = p_spi->bodyRotation(); std::vector<double> CJ; CJ.resize(9); for(std::vector<double>::size_type pos = 0; pos < p_cacheTime.size(); pos++) { double et = p_cacheTime.at(pos); rtime.push_back((et - GetBaseTime()) / GetTimeScale()); double angle1 = function1.Evaluate(rtime); double angle2 = function2.Evaluate(rtime); double angle3 = function3.Evaluate(rtime); rtime.clear(); // Get the first angle back into the range Naif expects [180.,180.] if(angle1 < -1 * pi_c()) { angle1 += twopi_c(); } else if(angle1 > pi_c()) { angle1 -= twopi_c(); } eul2m_c((SpiceDouble) angle3, (SpiceDouble) angle2, (SpiceDouble) angle1, p_axis3, p_axis2, p_axis1, CI); mxm_c((SpiceDouble( *)[3]) & (p_jitter->SetEphemerisTimeHPF(et))[0], CI, CI); prot->SetEphemerisTime(et); mxm_c((SpiceDouble( *)[3]) & (p_cacheIB.at(pos))[0], (SpiceDouble( *)[3]) & (prot->Matrix())[0], IJ); mxm_c(CI, IJ, (SpiceDouble( *)[3]) &CJ[0]); p_cache.push_back(CJ); // J2000 to constant frame } // Set source to cache to get updated values SetSource(SpiceRotation::Memcache); // Make sure SetEphemerisTime updates the matrix by resetting it twice (in case the first one // matches the current et. p_et is private and not available from the child class NaifStatus::CheckErrors(); SetEphemerisTime(p_cacheTime[0]); SetEphemerisTime(p_cacheTime[1]); NaifStatus::CheckErrors(); }
int main() { function2 f2; const function2 cf2; function3 f3; handler2 h2; const handler2 ch2; handler3 h3; std::experimental::loop_scheduler scheduler; std::experimental::executor ex = make_executor(scheduler); ex = std::experimental::system_executor(); assert(&ex.context() == &std::experimental::system_executor().context()); std::experimental::post(ex.wrap(function1), handler1); std::experimental::post(ex.wrap(function1), &handler1); std::experimental::post(ex.wrap(function1), handler2()); std::experimental::post(ex.wrap(function1), h2); std::experimental::post(ex.wrap(function1), ch2); std::experimental::post(ex.wrap(function1), handler3()); std::experimental::post(ex.wrap(function1), std::move(h3)); std::future<void> fut1 = std::experimental::post(ex.wrap(function1), std::experimental::use_future); fut1.get(); std::experimental::post(ex.wrap(&function1), handler1); std::experimental::post(ex.wrap(&function1), &handler1); std::experimental::post(ex.wrap(&function1), handler2()); std::experimental::post(ex.wrap(&function1), h2); std::experimental::post(ex.wrap(&function1), ch2); std::experimental::post(ex.wrap(&function1), handler3()); std::experimental::post(ex.wrap(&function1), std::move(h3)); std::future<void> fut2 = std::experimental::post(ex.wrap(&function1), std::experimental::use_future); fut2.get(); std::experimental::post(ex.wrap(function2()), handler1); std::experimental::post(ex.wrap(function2()), &handler1); std::experimental::post(ex.wrap(function2()), handler2()); std::experimental::post(ex.wrap(function2()), h2); std::experimental::post(ex.wrap(function2()), ch2); std::experimental::post(ex.wrap(function2()), handler3()); std::experimental::post(ex.wrap(function2()), std::move(h3)); std::future<void> fut3 = std::experimental::post(ex.wrap(function2()), std::experimental::use_future); fut3.get(); std::experimental::post(ex.wrap(f2), handler1); std::experimental::post(ex.wrap(f2), &handler1); std::experimental::post(ex.wrap(f2), handler2()); std::experimental::post(ex.wrap(f2), h2); std::experimental::post(ex.wrap(f2), ch2); std::experimental::post(ex.wrap(f2), handler3()); std::experimental::post(ex.wrap(f2), std::move(h3)); std::future<void> fut4 = std::experimental::post(ex.wrap(f2), std::experimental::use_future); fut4.get(); std::experimental::post(ex.wrap(cf2), handler1); std::experimental::post(ex.wrap(cf2), &handler1); std::experimental::post(ex.wrap(cf2), handler2()); std::experimental::post(ex.wrap(cf2), h2); std::experimental::post(ex.wrap(cf2), ch2); std::experimental::post(ex.wrap(cf2), handler3()); std::experimental::post(ex.wrap(cf2), std::move(h3)); std::future<void> fut5 = std::experimental::post(ex.wrap(cf2), std::experimental::use_future); fut5.get(); std::experimental::post(ex.wrap(function3()), handler1); std::experimental::post(ex.wrap(function3()), &handler1); std::experimental::post(ex.wrap(function3()), handler2()); std::experimental::post(ex.wrap(function3()), h2); std::experimental::post(ex.wrap(function3()), ch2); std::experimental::post(ex.wrap(function3()), handler3()); std::experimental::post(ex.wrap(function3()), std::move(h3)); std::future<void> fut6 = std::experimental::post(ex.wrap(function3()), std::experimental::use_future); fut6.get(); std::experimental::post(ex.wrap(std::move(f3)), handler1); std::experimental::post(ex.wrap(std::move(f3)), &handler1); std::experimental::post(ex.wrap(std::move(f3)), handler2()); std::experimental::post(ex.wrap(std::move(f3)), h2); std::experimental::post(ex.wrap(std::move(f3)), ch2); std::experimental::post(ex.wrap(std::move(f3)), handler3()); std::experimental::post(ex.wrap(std::move(f3)), std::move(h3)); std::future<void> fut7 = std::experimental::post(ex.wrap(std::move(f3)), std::experimental::use_future); fut7.get(); std::this_thread::sleep_for(std::chrono::seconds(1)); assert(function_count == 56); assert(handler_count == 49); }
int main(int argc,char *argv[]) { float x0,y0,x00,y00,t0,d1,d2,d3,o1,o2,o3,k11,k21,k31,k41,k12,k22,k32,k42; float kxi,gamma,omega,phi;/*parameter define*/ int i,j,k,n1,n2,n3,sn1,pow1,pow2; double h; float *inpsg,*xt,*xt1,*re; sf_complex *out1; sf_file in, out, restor=NULL; bool verb,cosine; sf_init (argc, argv); in = sf_input("in"); out = sf_output("out"); if (NULL != sf_getstring ("restor")) { restor = sf_input("restor"); } else { restor = NULL; sn1=1; } sf_setformat(out,"native_complex"); if (!sf_histint(in,"n1",&n1)) sf_error("No n1= in input"); if (!sf_histfloat(in,"d1",&d1)) sf_error("No d1= in input"); if (!sf_histfloat(in,"o1",&o1)) sf_error("No o1= in input"); if (!sf_histint(in,"n2",&n2)) n2=1; if (!sf_histfloat(in,"d2",&d2)) d2=1; if (!sf_histfloat(in,"o2",&o2)) o2=1; if (!sf_histint(in,"n3",&n3)) n3=1; if (!sf_histfloat(in,"d3",&d3)) d3=1; if (!sf_histfloat(in,"o3",&o3)) o3=1; if(!sf_getfloat("gamma",&gamma)) gamma=0.75; /*strength of external force*/ if(!sf_getfloat("omega",&omega)) omega=1; /*angular frequence of external force*/ if(!sf_getfloat("kxi",&kxi)) kxi=1; /*adjustment for input signal*/ if(!sf_getfloat("x0",&x0)) x0=0; /*initial value of x0*/ if(!sf_getfloat("y0",&y0)) y0=0; /*initial value of y0*/ if(!sf_getint("pow1",&pow1)) pow1=1; /*power of first non-linear restitution term*/ if(!sf_getint("pow2",&pow2)) pow2=3; /*power of second non-linear restitution term*/ if(!sf_getfloat("phi",&phi)) phi=0.; /*phase of cosine signal unit=pi*/ if(!sf_getbool("verb",&verb)) verb = false; /* verbosity flag */ if(!sf_getbool("cosine",&cosine)) cosine = true; /* if n need extenal input for periodic restoring force */ if (NULL != restor){ if (!sf_histint(restor,"n1",&sn1)) sf_error("No n1= in s"); if (n1>sn1) sf_error("insufficient lenth of external force"); } h=d1; /*step lenth of R-K4*/ re = sf_floatalloc(sn1); inpsg = sf_floatalloc(n1*n2); xt = sf_floatalloc(n1*n2); xt1 = sf_floatalloc(n1*n2); out1 = sf_complexalloc(n1*n2); if (NULL != restor) { sf_floatread(re,sn1,restor); }else { for (i=0;i<sn1; i++) re[i] = 0; } if(cosine) { for(k = 0; k < n3 ; k++) { sf_floatread(inpsg,n1*n2,in); x00=x0,y00=y0; t0=0; if(verb) sf_warning("step %d of %d;",k,n3); for(j = 0;j < n2;j++) { x00=x0,y00=y0; t0=0; for(i = 0;i < n1;i++){ k11 = function1(t0,x00,y00,omega); k12 = function2(t0,x00,y00,inpsg[i+j*n1],kxi, gamma,omega,pow1,pow2,phi); k21 = function1(t0+h/2,x00+k11*h/2,y00+k12*h/2,omega); k22 = function2(t0+h/2,x00+k11*h/2, y00+k12*h/2,inpsg[i+j*n1],kxi, gamma,omega,pow1,pow2,phi); k31 = function1(t0+h/2,x00+k21*h/2,y00+k22*h/2,omega); k32 = function2(t0+h/2,x00+k21*h/2, y00+k22*h/2,inpsg[i+j*n1],kxi, gamma,omega,pow1,pow2,phi); k41 = function1(t0+h,x00+k31*h,y00+k32*h,omega); k42 = function2(t0+h,x00+k31*h,y00+k32*h,inpsg[i+j*n1], kxi,gamma,omega,pow1,pow2,phi); x00+= h*(k11+2*k21+2*k31+k41)/6; y00+= h*(k12+2*k22+2*k32+k42)/6; t0+= h; xt[i+j*n1]=x00,xt1[i+j*n1]=y00; } } for(i=0;i < n1*n2;i++) { out1[i] = sf_cmplx(xt[i],xt1[i]); } sf_complexwrite(out1,n1*n2,out); } }else { for(k = 0; k < n3 ; k++) { sf_floatread(inpsg,n1*n2,in); x00=x0,y00=y0; t0=0; if(verb) sf_warning("step %d of %d;",k,n3); for(j = 0;j < n2;j++) { x00=x0,y00=y0; t0=0; for(i = 0;i < n1;i++) { k11 = function1(t0,x00,y00,omega); k12 = function3(t0,x00,y00,inpsg[i+j*n1],kxi, gamma,omega,pow1,pow2,re[i]); k21 = function1(t0+h/2,x00+k11*h/2,y00+k12*h/2,omega); k22 = function3(t0+h/2,x00+k11*h/2, y00+k12*h/2,inpsg[i+j*n1],kxi, gamma,omega,pow1,pow2,re[i]); k31 = function1(t0+h/2,x00+k21*h/2,y00+k22*h/2,omega); k32 = function3(t0+h/2,x00+k21*h/2, y00+k22*h/2,inpsg[i+j*n1],kxi, gamma,omega,pow1,pow2,re[i]); k41 = function1(t0+h,x00+k31*h,y00+k32*h,omega); k42 = function3(t0+h,x00+k31*h,y00+k32*h,inpsg[i+j*n1], kxi,gamma,omega,pow1,pow2,re[i]); x00+= h*(k11+2*k21+2*k31+k41)/6; y00+= h*(k12+2*k22+2*k32+k42)/6; t0+= h; xt[i+j*n1]=x00,xt1[i+j*n1]=y00; } } for(i=0;i < n1*n2;i++) { out1[i] = sf_cmplx(xt[i],xt1[i]); } sf_complexwrite(out1,n1*n2,out); } } exit(0); }
int main() { function2 f2; const function2 cf2; function3 f3; handler2 h2; const handler2 ch2; handler3 h3; invoke(std::experimental::chain<void(int)>(function1)); invoke(std::experimental::chain<void(int)>(function1, handler1)); invoke(std::experimental::chain<void(int)>(function1, &handler1)); invoke(std::experimental::chain<void(int)>(function1, handler2())); invoke(std::experimental::chain<void(int)>(function1, h2)); invoke(std::experimental::chain<void(int)>(function1, ch2)); invoke(std::experimental::chain<void(int)>(function1, handler3())); invoke(std::experimental::chain<void(int)>(function1, std::move(h3))); invoke(std::experimental::chain<void(int)>(&function1)); invoke(std::experimental::chain<void(int)>(&function1, handler1)); invoke(std::experimental::chain<void(int)>(&function1, &handler1)); invoke(std::experimental::chain<void(int)>(&function1, handler2())); invoke(std::experimental::chain<void(int)>(&function1, h2)); invoke(std::experimental::chain<void(int)>(&function1, ch2)); invoke(std::experimental::chain<void(int)>(&function1, handler3())); invoke(std::experimental::chain<void(int)>(&function1, std::move(h3))); invoke(std::experimental::chain<void(int)>(function2())); invoke(std::experimental::chain<void(int)>(function2(), handler1)); invoke(std::experimental::chain<void(int)>(function2(), &handler1)); invoke(std::experimental::chain<void(int)>(function2(), handler2())); invoke(std::experimental::chain<void(int)>(function2(), h2)); invoke(std::experimental::chain<void(int)>(function2(), ch2)); invoke(std::experimental::chain<void(int)>(function2(), handler3())); invoke(std::experimental::chain<void(int)>(function2(), std::move(h3))); invoke(std::experimental::chain<void(int)>(f2)); invoke(std::experimental::chain<void(int)>(f2, handler1)); invoke(std::experimental::chain<void(int)>(f2, &handler1)); invoke(std::experimental::chain<void(int)>(f2, handler2())); invoke(std::experimental::chain<void(int)>(f2, h2)); invoke(std::experimental::chain<void(int)>(f2, ch2)); invoke(std::experimental::chain<void(int)>(f2, handler3())); invoke(std::experimental::chain<void(int)>(f2, std::move(h3))); invoke(std::experimental::chain<void(int)>(cf2)); invoke(std::experimental::chain<void(int)>(cf2, handler1)); invoke(std::experimental::chain<void(int)>(cf2, &handler1)); invoke(std::experimental::chain<void(int)>(cf2, handler2())); invoke(std::experimental::chain<void(int)>(cf2, h2)); invoke(std::experimental::chain<void(int)>(cf2, ch2)); invoke(std::experimental::chain<void(int)>(cf2, handler3())); invoke(std::experimental::chain<void(int)>(cf2, std::move(h3))); invoke(std::experimental::chain<void(int)>(function3())); invoke(std::experimental::chain<void(int)>(function3(), handler1)); invoke(std::experimental::chain<void(int)>(function3(), &handler1)); invoke(std::experimental::chain<void(int)>(function3(), handler2())); invoke(std::experimental::chain<void(int)>(function3(), h2)); invoke(std::experimental::chain<void(int)>(function3(), ch2)); invoke(std::experimental::chain<void(int)>(function3(), handler3())); invoke(std::experimental::chain<void(int)>(function3(), std::move(h3))); invoke(std::experimental::chain<void(int)>(std::move(f3))); invoke(std::experimental::chain<void(int)>(std::move(f3), handler1)); invoke(std::experimental::chain<void(int)>(std::move(f3), &handler1)); invoke(std::experimental::chain<void(int)>(std::move(f3), handler2())); invoke(std::experimental::chain<void(int)>(std::move(f3), h2)); invoke(std::experimental::chain<void(int)>(std::move(f3), ch2)); invoke(std::experimental::chain<void(int)>(std::move(f3), handler3())); invoke(std::experimental::chain<void(int)>(std::move(f3), std::move(h3))); assert(function_count == 56); assert(handler_count == 49); }
int main (int argc, char const * argv []) { static char const * optv [] = { "f:g:n:p:iqrvw:z", "", "PTS Module Controller", "f f\tport is (f) [" PTSCTL_PORT "]", "g n\tline ground attenuation is (n) [" LITERAL (PTSCTL_GRND_ATTN) "]", "n n\tline neutral attenuation is (n) [" LITERAL (PTSCTL_LINE_ATTN) "]", "p n\tpower is (n) [" LITERAL (PTSCTL_MODE) "]", "q\tquiet mode", "r\tread and display attenuator settings", "v\tverbose mode", "w n\twait (n) millseconds [" LITERAL (PTSCTL_WAIT) "]", (char const *) (0) }; struct _file_ port = { -1, PTSCTL_PORT }; #if defined (WIN32) HANDLE hSerial; DCB dcbSerial = { 0 }; #else struct termios termios; #endif char const * units = PTSCTL_UNITS; unsigned wait = PTSCTL_WAIT; unsigned mode = PTSCTL_MODE; unsigned echo = PTSCTL_ECHO; unsigned line = PTSCTL_LINE_ATTN; unsigned grnd = PTSCTL_GRND_ATTN; unsigned data = 0; flag_t flags = (flag_t)(0); signed c; optind = 1; if (getenv ("PTSCTL")) { port.name = strdup (getenv ("PTSCTL")); } while ((c = getoptv (argc, argv, optv)) != -1) { switch (c) { case 'f': port.name = optarg; break; case 'g': _setbits (flags, PTSCTL_CHANGE); grnd = (unsigned)(uintspec (optarg, 0, 0x7F)); break; case 'n': _setbits (flags, PTSCTL_CHANGE); line = (unsigned)(uintspec (optarg, 0, 0x7F)); break; case 'p': _setbits (flags, PTSCTL_CHANGE); mode = (unsigned)(uintspec (synonym (optarg, modes, SIZEOF (modes)), 0, 1)); break; case 'w': wait = (unsigned)(uintspec (optarg, 5, 100)); break; case 'q': _setbits (flags, PTSCTL_SILENCE); break; case 'r': _setbits (flags, PTSCTL_DISPLAY); break; case 'v': _setbits (flags, PTSCTL_VERBOSE); break; case 'z': _setbits (flags, PTSCTL_ITERATE); break; default: break; } } argc -= optind; argv += optind; if (argc) { error (1, ENOTSUP, ERROR_TOOMANY); } #if defined (WIN32) hSerial = CreateFile (port.name, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); if (hSerial == INVALID_HANDLE_VALUE) { error (1, errno, FILE_CANTOPEN, port.name); } dcbSerial.DCBlength = sizeof (dcbSerial); if (!GetCommState (hSerial, &dcbSerial)) { error (1, 0, FILE_CANTREAD " state", port.name); } dcbSerial.BaudRate = CBR_9600; dcbSerial.ByteSize = 8; dcbSerial.StopBits = ONESTOPBIT; dcbSerial.Parity = NOPARITY; if (!SetCommState (hSerial, &dcbSerial)) { error (1, 0, FILE_CANTSAVE " state", port.name); } CloseHandle (hSerial); if ((port.file = open (port.name, O_BINARY | O_RDWR)) == -1) { error (1, errno, FILE_CANTOPEN, port.name); } #else if ((port.file = open (port.name, O_RDWR|O_NOCTTY|O_NDELAY)) == -1) { error (1, 0, FILE_CANTOPEN, port.name); } tcgetattr (port.file, &termios); termios.c_cflag = CS8; cfsetospeed (&termios, B9600); tcsetattr (port.file, TCSANOW, &termios); #endif function1 (&port, units, wait, echo); if (_anyset (flags, PTSCTL_CHANGE)) { data = line << 8 | grnd << 1 | mode; function2 (&port, units, wait, data); } if (_anyset (flags, PTSCTL_DISPLAY)) { function3 (&port, units, wait); } if (_anyset (flags, PTSCTL_ITERATE)) { function4 (&port, units, wait); } close (port.file); return (0); }
int main() { function2 f2; const function2 cf2; function3 f3; handler2 h2; const handler2 ch2; handler3 h3; std::experimental::thread_pool pool; auto abs_time = std::chrono::steady_clock::now() + std::chrono::milliseconds(100); std::experimental::dispatch_at(abs_time, pool, function1, handler1); std::experimental::dispatch_at(abs_time, pool, function1, &handler1); std::experimental::dispatch_at(abs_time, pool, function1, handler2()); std::experimental::dispatch_at(abs_time, pool, function1, h2); std::experimental::dispatch_at(abs_time, pool, function1, ch2); std::experimental::dispatch_at(abs_time, pool, function1, handler3()); std::experimental::dispatch_at(abs_time, pool, function1, std::move(h3)); std::future<int> fut1 = std::experimental::dispatch_at(abs_time, pool, function1, std::experimental::use_future); fut1.get(); std::experimental::dispatch_at(abs_time, pool, &function1, handler1); std::experimental::dispatch_at(abs_time, pool, &function1, &handler1); std::experimental::dispatch_at(abs_time, pool, &function1, handler2()); std::experimental::dispatch_at(abs_time, pool, &function1, h2); std::experimental::dispatch_at(abs_time, pool, &function1, ch2); std::experimental::dispatch_at(abs_time, pool, &function1, handler3()); std::experimental::dispatch_at(abs_time, pool, &function1, std::move(h3)); std::future<int> fut2 = std::experimental::dispatch_at(abs_time, pool, &function1, std::experimental::use_future); fut2.get(); std::experimental::dispatch_at(abs_time, pool, function2(), handler1); std::experimental::dispatch_at(abs_time, pool, function2(), &handler1); std::experimental::dispatch_at(abs_time, pool, function2(), handler2()); std::experimental::dispatch_at(abs_time, pool, function2(), h2); std::experimental::dispatch_at(abs_time, pool, function2(), ch2); std::experimental::dispatch_at(abs_time, pool, function2(), handler3()); std::experimental::dispatch_at(abs_time, pool, function2(), std::move(h3)); std::future<int> fut3 = std::experimental::dispatch_at(abs_time, pool, function2(), std::experimental::use_future); fut3.get(); std::experimental::dispatch_at(abs_time, pool, f2, handler1); std::experimental::dispatch_at(abs_time, pool, f2, &handler1); std::experimental::dispatch_at(abs_time, pool, f2, handler2()); std::experimental::dispatch_at(abs_time, pool, f2, h2); std::experimental::dispatch_at(abs_time, pool, f2, ch2); std::experimental::dispatch_at(abs_time, pool, f2, handler3()); std::experimental::dispatch_at(abs_time, pool, f2, std::move(h3)); std::future<int> fut4 = std::experimental::dispatch_at(abs_time, pool, f2, std::experimental::use_future); fut4.get(); std::experimental::dispatch_at(abs_time, pool, cf2, handler1); std::experimental::dispatch_at(abs_time, pool, cf2, &handler1); std::experimental::dispatch_at(abs_time, pool, cf2, handler2()); std::experimental::dispatch_at(abs_time, pool, cf2, h2); std::experimental::dispatch_at(abs_time, pool, cf2, ch2); std::experimental::dispatch_at(abs_time, pool, cf2, handler3()); std::experimental::dispatch_at(abs_time, pool, cf2, std::move(h3)); std::future<int> fut5 = std::experimental::dispatch_at(abs_time, pool, cf2, std::experimental::use_future); fut5.get(); std::experimental::dispatch_at(abs_time, pool, function3(), handler1); std::experimental::dispatch_at(abs_time, pool, function3(), &handler1); std::experimental::dispatch_at(abs_time, pool, function3(), handler2()); std::experimental::dispatch_at(abs_time, pool, function3(), h2); std::experimental::dispatch_at(abs_time, pool, function3(), ch2); std::experimental::dispatch_at(abs_time, pool, function3(), handler3()); std::experimental::dispatch_at(abs_time, pool, function3(), std::move(h3)); std::future<int> fut6 = std::experimental::dispatch_at(abs_time, pool, function3(), std::experimental::use_future); fut6.get(); std::experimental::dispatch_at(abs_time, pool, std::move(f3), handler1); std::experimental::dispatch_at(abs_time, pool, std::move(f3), &handler1); std::experimental::dispatch_at(abs_time, pool, std::move(f3), handler2()); std::experimental::dispatch_at(abs_time, pool, std::move(f3), h2); std::experimental::dispatch_at(abs_time, pool, std::move(f3), ch2); std::experimental::dispatch_at(abs_time, pool, std::move(f3), handler3()); std::experimental::dispatch_at(abs_time, pool, std::move(f3), std::move(h3)); std::future<int> fut7 = std::experimental::dispatch_at(abs_time, pool, std::move(f3), std::experimental::use_future); fut7.get(); std::this_thread::sleep_for(std::chrono::seconds(1)); assert(function_count == 56); assert(handler_count == 49); std::future<int> fut8 = std::experimental::dispatch_at(abs_time, pool, function_throw, std::experimental::use_future); try { fut8.get(); assert(0); } catch (std::exception& e) { assert(e.what() == std::string("oops")); } std::future<int> fut9 = std::experimental::dispatch_at(abs_time, pool, std::experimental::package(function_throw)); try { fut9.get(); assert(0); } catch (std::exception& e) { assert(e.what() == std::string("oops")); } }