X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/093776b9da6272771c04f848d9bd5ee28f5e06e3..6ade1c748396ae71562fd718e8409de61ab00148:/teshsuite/s4u/storage_client_server/storage_client_server.cpp diff --git a/teshsuite/s4u/storage_client_server/storage_client_server.cpp b/teshsuite/s4u/storage_client_server/storage_client_server.cpp index 480350504f..9352f45839 100644 --- a/teshsuite/s4u/storage_client_server/storage_client_server.cpp +++ b/teshsuite/s4u/storage_client_server/storage_client_server.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2013-2020. 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,7 +11,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(storage, "Messages specific for this simulation"); -static void display_disk_properties(simgrid::s4u::Disk* disk) +static void display_disk_properties(const simgrid::s4u::Disk* disk) { const std::unordered_map* props = disk->get_properties(); if (not props->empty()) { @@ -51,17 +51,17 @@ static void hsm_put(const std::string& remote_host, const std::string& src, cons // Send file XBT_INFO("%s sends %llu to %s", simgrid::s4u::this_actor::get_cname(), read_size, remote_host.c_str()); - std::string* payload = new std::string(simgrid::xbt::string_printf("%s %llu", dest.c_str(), read_size)); - simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(remote_host); + auto* payload = new std::string(simgrid::xbt::string_printf("%s %llu", dest.c_str(), read_size)); + auto* mailbox = simgrid::s4u::Mailbox::by_name(remote_host); mailbox->put(payload, read_size); simgrid::s4u::this_actor::sleep_for(.4); } -static void display_disk_content(simgrid::s4u::Disk* disk) +static void display_disk_content(const simgrid::s4u::Disk* disk) { XBT_INFO("*** Dump a disk ***"); XBT_INFO("Print the content of the disk: %s", disk->get_cname()); - std::map* content = disk->extension()->get_content(); + const auto* content = disk->extension()->get_content(); if (not content->empty()) { for (auto const& entry : *content) XBT_INFO(" %s size: %llu bytes", entry.first.c_str(), entry.second); @@ -74,7 +74,7 @@ static void get_set_disk_data(simgrid::s4u::Disk* disk) { XBT_INFO("*** GET/SET DATA for disk: %s ***", disk->get_cname()); - std::string* data = static_cast(disk->get_data()); + const std::string* data = static_cast(disk->get_data()); XBT_INFO("Get data: '%s'", data ? data->c_str() : "No User Data"); disk->set_data(new std::string("Some data")); data = static_cast(disk->get_data()); @@ -84,7 +84,6 @@ static void get_set_disk_data(simgrid::s4u::Disk* disk) static void dump_platform_disks() { - for (auto const& h : simgrid::s4u::Engine::get_instance()->get_all_hosts()) for (auto const& d : h->get_disks()) { if (h == d->get_host()) @@ -93,7 +92,7 @@ static void dump_platform_disks() } } -static void disk_info(simgrid::s4u::Host* host) +static void disk_info(const simgrid::s4u::Host* host) { XBT_INFO("*** Disk info on %s ***", host->get_cname()); @@ -127,17 +126,15 @@ static void server() simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(simgrid::s4u::this_actor::get_host()->get_cname()); XBT_INFO("Server waiting for transfers ..."); - while (1) { - std::string* msg = static_cast(mailbox->get()); + while (true) { + auto msg = mailbox->get_unique(); if (*msg == "finalize") { // Shutdown ... - delete msg; break; } else { // Receive file to save size_t pos = msg->find(' '); std::string dest = msg->substr(0, pos); sg_size_t size_to_write = std::stoull(msg->substr(pos + 1)); write_local_file(dest, size_to_write); - delete msg; } }