X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/20fb1d8f699a02bdfd23130097cf7cf3d11f5840..a6957f33a8f941b49d923e43675d50fe2671a554:/examples/s4u/cloud-simple/s4u-cloud-simple.cpp diff --git a/examples/s4u/cloud-simple/s4u-cloud-simple.cpp b/examples/s4u/cloud-simple/s4u-cloud-simple.cpp index 61f0bd75a7..1d478691b6 100644 --- a/examples/s4u/cloud-simple/s4u-cloud-simple.cpp +++ b/examples/s4u/cloud-simple/s4u-cloud-simple.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2007-2018. 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. */ @@ -11,17 +11,17 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example") static void computation_fun() { - double clock_sta = simgrid::s4u::Engine::getClock(); + double clock_sta = simgrid::s4u::Engine::get_clock(); simgrid::s4u::this_actor::execute(1000000); - double clock_end = simgrid::s4u::Engine::getClock(); + double clock_end = simgrid::s4u::Engine::get_clock(); - XBT_INFO("%s:%s task executed %g", simgrid::s4u::this_actor::getHost()->getCname(), - simgrid::s4u::this_actor::getCname(), clock_end - clock_sta); + XBT_INFO("%s:%s task executed %g", simgrid::s4u::this_actor::get_host()->get_cname(), + simgrid::s4u::this_actor::get_cname(), clock_end - clock_sta); } static void launch_computation_worker(s4u_Host* host) { - simgrid::s4u::Actor::createActor("compute", host, computation_fun); + simgrid::s4u::Actor::create("compute", host, computation_fun); } struct s_payload { @@ -32,39 +32,39 @@ struct s_payload { static void communication_tx_fun(std::vector args) { - simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::byName(args.at(0)); - struct s_payload* payload = xbt_new(struct s_payload, 1); - payload->tx_actor_name = simgrid::s4u::Actor::self()->getCname(); - payload->tx_host = simgrid::s4u::this_actor::getHost(); - payload->clock_sta = simgrid::s4u::Engine::getClock(); + simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(args.at(0)); + s_payload* payload = new s_payload; + payload->tx_actor_name = simgrid::s4u::Actor::self()->get_cname(); + payload->tx_host = simgrid::s4u::this_actor::get_host(); + payload->clock_sta = simgrid::s4u::Engine::get_clock(); mbox->put(payload, 1000000); } static void communication_rx_fun(std::vector args) { - const char* actor_name = simgrid::s4u::Actor::self()->getCname(); - const char* host_name = simgrid::s4u::this_actor::getHost()->getCname(); - simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::byName(args.at(0)); + const char* actor_name = simgrid::s4u::Actor::self()->get_cname(); + const char* host_name = simgrid::s4u::this_actor::get_host()->get_cname(); + simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(args.at(0)); struct s_payload* payload = static_cast(mbox->get()); - double clock_end = simgrid::s4u::Engine::getClock(); + double clock_end = simgrid::s4u::Engine::get_clock(); - XBT_INFO("%s:%s to %s:%s => %g sec", payload->tx_host->getCname(), payload->tx_actor_name, host_name, actor_name, + XBT_INFO("%s:%s to %s:%s => %g sec", payload->tx_host->get_cname(), payload->tx_actor_name, host_name, actor_name, clock_end - payload->clock_sta); - xbt_free(payload); + delete payload; } static void launch_communication_worker(s4u_Host* tx_host, s4u_Host* rx_host) { - std::string mbox_name = std::string("MBOX:") + tx_host->getCname() + "-" + rx_host->getCname(); + std::string mbox_name = std::string("MBOX:") + tx_host->get_cname() + "-" + rx_host->get_cname(); std::vector args; args.push_back(mbox_name); - simgrid::s4u::Actor::createActor("comm_tx", tx_host, communication_tx_fun, args); + simgrid::s4u::Actor::create("comm_tx", tx_host, communication_tx_fun, args); - simgrid::s4u::Actor::createActor("comm_rx", rx_host, communication_rx_fun, args); + simgrid::s4u::Actor::create("comm_rx", rx_host, communication_rx_fun, args); } static void master_main() @@ -193,10 +193,7 @@ static void master_main() " network one"); XBT_INFO("### Relocate VM0 between PM0 and PM1"); vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1); - s_vm_params_t params; - memset(¶ms, 0, sizeof(params)); - vm0->setParameters(¶ms); - vm0->setRamsize(1L * 1024 * 1024 * 1024); // 1GiB + vm0->set_ramsize(1L * 1024 * 1024 * 1024); // 1GiB vm0->start(); launch_communication_worker(vm0, pm2); @@ -213,13 +210,13 @@ int main(int argc, char* argv[]) { simgrid::s4u::Engine e(&argc, argv); sg_vm_live_migration_plugin_init(); - e.loadPlatform(argv[1]); /* - Load the platform description */ + e.load_platform(argv[1]); /* - Load the platform description */ - simgrid::s4u::Actor::createActor("master_", simgrid::s4u::Host::by_name("Fafard"), master_main); + simgrid::s4u::Actor::create("master_", simgrid::s4u::Host::by_name("Fafard"), master_main); e.run(); - XBT_INFO("Simulation time %g", e.getClock()); + XBT_INFO("Simulation time %g", e.get_clock()); return 0; }