X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/cdcc6f10f0ba3de1b01e4c910fa1966114350ae6..043ae887210f9720621e83305f5fb434604f6b83:/teshsuite/simix/generic-simcalls/generic-simcalls.cpp diff --git a/teshsuite/simix/generic-simcalls/generic-simcalls.cpp b/teshsuite/simix/generic-simcalls/generic-simcalls.cpp index 8e9ffc4206..74cdbbed95 100644 --- a/teshsuite/simix/generic-simcalls/generic-simcalls.cpp +++ b/teshsuite/simix/generic-simcalls/generic-simcalls.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016-2018. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -8,6 +8,7 @@ #include +#include #include #include #include @@ -26,11 +27,11 @@ static simgrid::kernel::Future kernel_wait_until(double date) { auto promise = std::make_shared>(); auto future = promise->get_future(); - SIMIX_timer_set(date, [promise] { promise->set_value(); }); + simgrid::simix::Timer::set(date, [promise] { promise->set_value(); }); return future; } -static int master(int argc, char* argv[]) +static void master() { // Test the simple immediate execution: XBT_INFO("Start"); @@ -38,19 +39,19 @@ static int master(int argc, char* argv[]) XBT_INFO("kernel, returned"); // Synchronize on a successful Future: - simgrid::simix::kernelSync([] { - return kernel_wait_until(10).then([](simgrid::kernel::Future future) { - future.get(); - XBT_INFO("kernelSync with void"); + simgrid::simix::kernel_sync([] { + return kernel_wait_until(10).then([](simgrid::kernel::Future f) { + f.get(); + XBT_INFO("kernel_sync with void"); }); }); - XBT_INFO("kernelSync with void, returned"); + XBT_INFO("kernel_sync with void, returned"); // Synchronize on a failing Future: try { - simgrid::simix::kernelSync([] { - return kernel_wait_until(20).then([](simgrid::kernel::Future future) { - future.get(); + simgrid::simix::kernel_sync([] { + return kernel_wait_until(20).then([](simgrid::kernel::Future f) { + f.get(); throw example::exception("Exception throwed from kernel_defer"); }); }); @@ -60,31 +61,31 @@ static int master(int argc, char* argv[]) } // Synchronize on a successul Future and get the value: - int res = simgrid::simix::kernelSync([] { - return kernel_wait_until(30).then([](simgrid::kernel::Future future) { - future.get(); - XBT_INFO("kernelSync with value"); + int res = simgrid::simix::kernel_sync([] { + return kernel_wait_until(30).then([](simgrid::kernel::Future f) { + f.get(); + XBT_INFO("kernel_sync with value"); return 42; }); }); - XBT_INFO("kernelSync with value returned with %i", res); + XBT_INFO("kernel_sync with value returned with %i", res); // Synchronize on a successul Future and get the value: - simgrid::simix::Future future = simgrid::simix::kernelAsync([] { - return kernel_wait_until(50).then([](simgrid::kernel::Future future) { - future.get(); - XBT_INFO("kernelAsync with value"); + simgrid::simix::Future future = simgrid::simix::kernel_async([] { + return kernel_wait_until(50).then([](simgrid::kernel::Future f) { + f.get(); + XBT_INFO("kernel_async with value"); return 43; }); }); res = future.get(); - XBT_INFO("kernelAsync with value returned with %i", res); + XBT_INFO("kernel_async with value returned with %i", res); // Synchronize on a successul Future and get the value: - future = simgrid::simix::kernelAsync([] { - return kernel_wait_until(60).then([](simgrid::kernel::Future future) { - future.get(); - XBT_INFO("kernelAsync with value"); + future = simgrid::simix::kernel_async([] { + return kernel_wait_until(60).then([](simgrid::kernel::Future f) { + f.get(); + XBT_INFO("kernel_async with value"); return 43; }); }); @@ -92,9 +93,7 @@ static int master(int argc, char* argv[]) future.wait(); XBT_INFO("The future is %s", future.is_ready() ? "ready" : "not ready"); res = future.get(); - XBT_INFO("kernelAsync with value returned with %i", res); - - return 0; + XBT_INFO("kernel_async with value returned with %i", res); } } @@ -102,9 +101,8 @@ int main(int argc, char* argv[]) { SIMIX_global_init(&argc, argv); xbt_assert(argc == 2, "Usage: %s platform.xml\n", argv[0]); - SIMIX_function_register("master", example::master); - SIMIX_create_environment(argv[1]); - simcall_process_create("master", example::master, NULL, sg_host_by_name("Tremblay"), 0, NULL, NULL); + simgrid_load_platform(argv[1]); + simcall_process_create("master", example::master, NULL, sg_host_by_name("Tremblay"), NULL); SIMIX_run(); return 0; }