X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/edca9509f1ec94a851e0265c1876a4733f4fff87..39c935d6d5ee86d153f6f7e6a10d723ae7c57f6f:/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 6bc8cf51cd..c2a1ecd562 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-2021. 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,8 +8,9 @@ #include -#include #include +#include +#include #include #include #include @@ -27,21 +28,21 @@ 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"); - simgrid::simix::simcall([] { XBT_INFO("kernel"); }); + simgrid::kernel::actor::simcall([] { XBT_INFO("kernel"); }); XBT_INFO("kernel, returned"); // Synchronize on a successful Future: simgrid::simix::kernel_sync([] { - return kernel_wait_until(10).then([](simgrid::kernel::Future future) { - future.get(); + return kernel_wait_until(10).then([](simgrid::kernel::Future f) { + f.get(); XBT_INFO("kernel_sync with void"); }); }); @@ -50,9 +51,9 @@ static int master(int argc, char* argv[]) // Synchronize on a failing Future: try { simgrid::simix::kernel_sync([] { - return kernel_wait_until(20).then([](simgrid::kernel::Future future) { - future.get(); - throw example::exception("Exception throwed from kernel_defer"); + return kernel_wait_until(20).then([](simgrid::kernel::Future f) { + f.get(); + throw example::exception("Exception thrown from kernel_defer"); }); }); XBT_ERROR("No exception caught!"); @@ -60,20 +61,20 @@ static int master(int argc, char* argv[]) XBT_INFO("Exception caught: %s", e.what()); } - // Synchronize on a successul Future and get the value: + // Synchronize on a successful Future and get the value: int res = simgrid::simix::kernel_sync([] { - return kernel_wait_until(30).then([](simgrid::kernel::Future future) { - future.get(); + return kernel_wait_until(30).then([](simgrid::kernel::Future f) { + f.get(); XBT_INFO("kernel_sync with value"); return 42; }); }); XBT_INFO("kernel_sync with value returned with %i", res); - // Synchronize on a successul Future and get the value: + // Synchronize on a successful Future and get the value: simgrid::simix::Future future = simgrid::simix::kernel_async([] { - return kernel_wait_until(50).then([](simgrid::kernel::Future future) { - future.get(); + return kernel_wait_until(50).then([](simgrid::kernel::Future f) { + f.get(); XBT_INFO("kernel_async with value"); return 43; }); @@ -81,10 +82,10 @@ static int master(int argc, char* argv[]) res = future.get(); XBT_INFO("kernel_async with value returned with %i", res); - // Synchronize on a successul Future and get the value: + // Synchronize on a successful Future and get the value: future = simgrid::simix::kernel_async([] { - return kernel_wait_until(60).then([](simgrid::kernel::Future future) { - future.get(); + return kernel_wait_until(60).then([](simgrid::kernel::Future f) { + f.get(); XBT_INFO("kernel_async with value"); return 43; }); @@ -94,18 +95,15 @@ static int master(int argc, char* argv[]) XBT_INFO("The future is %s", future.is_ready() ? "ready" : "not ready"); res = future.get(); XBT_INFO("kernel_async with value returned with %i", res); - - return 0; } } int main(int argc, char* argv[]) { - SIMIX_global_init(&argc, argv); + simgrid::s4u::Engine e(&argc, argv); xbt_assert(argc == 2, "Usage: %s platform.xml\n", argv[0]); - simgrid_register_function("master", example::master); - simgrid_load_platform(argv[1]); - simcall_process_create("master", example::master, NULL, sg_host_by_name("Tremblay"), 0, NULL, NULL); - SIMIX_run(); + e.load_platform(argv[1]); + simgrid::s4u::Actor::create("master", e.host_by_name("Tremblay"), example::master); + e.run(); return 0; }