X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/08e7455d67920bbd7a87f440d00f2c1e071314a0..ab71da4cf3e28f55f7aef47f5299519135429872:/src/msg/msg_comm.cpp diff --git a/src/msg/msg_comm.cpp b/src/msg/msg_comm.cpp index 3a4bca249b..049c669ff7 100644 --- a/src/msg/msg_comm.cpp +++ b/src/msg/msg_comm.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2004-2022. 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. */ @@ -13,8 +13,7 @@ #include "src/instr/instr_private.hpp" #include "src/msg/msg_private.hpp" -namespace simgrid { -namespace msg { +namespace simgrid::msg { bool Comm::test() { @@ -60,8 +59,7 @@ msg_error_t Comm::wait_for(double timeout) return status_; } -} // namespace msg -} // namespace simgrid +} // namespace simgrid::msg /** * @brief Checks whether a communication is done, and if yes, finalizes it. @@ -84,28 +82,27 @@ int MSG_comm_test(msg_comm_t comm) */ int MSG_comm_testany(const_xbt_dynar_t comms) { - int finished_index = -1; + ssize_t finished_index = -1; /* Create the equivalent array with SIMIX objects: */ - std::vector s_comms; + std::vector s_comms; s_comms.reserve(xbt_dynar_length(comms)); msg_comm_t comm; unsigned int cursor; - xbt_dynar_foreach (comms, cursor, comm) { - s_comms.push_back(static_cast(comm->s_comm->get_impl())); - } + xbt_dynar_foreach (comms, cursor, comm) + s_comms.push_back(comm->s_comm); msg_error_t status = MSG_OK; try { - finished_index = simcall_comm_testany(s_comms.data(), s_comms.size()); + finished_index = simgrid::s4u::Comm::test_any(s_comms); } catch (const simgrid::TimeoutException& e) { - finished_index = e.value; + finished_index = e.get_value(); status = MSG_TIMEOUT; } catch (const simgrid::CancelException& e) { - finished_index = e.value; + finished_index = e.get_value(); status = MSG_TASK_CANCELED; } catch (const simgrid::NetworkFailureException& e) { - finished_index = e.value; + finished_index = e.get_value(); status = MSG_TRANSFER_FAILURE; } @@ -120,7 +117,7 @@ int MSG_comm_testany(const_xbt_dynar_t comms) } } - return finished_index; + return static_cast(finished_index); } /** @brief Destroys the provided communication. */ @@ -161,28 +158,28 @@ void MSG_comm_waitall(msg_comm_t* comm, int nb_elem, double timeout) */ int MSG_comm_waitany(const_xbt_dynar_t comms) { - int finished_index = -1; + ssize_t finished_index = -1; /* Create the equivalent array with SIMIX objects: */ - std::vector s_comms; + std::vector s_comms; s_comms.reserve(xbt_dynar_length(comms)); msg_comm_t comm; unsigned int cursor; xbt_dynar_foreach (comms, cursor, comm) { - s_comms.push_back(static_cast(comm->s_comm->get_impl())); + s_comms.push_back(comm->s_comm); } msg_error_t status = MSG_OK; try { - finished_index = simcall_comm_waitany(s_comms.data(), s_comms.size(), -1); + finished_index = simgrid::s4u::Comm::wait_any_for(s_comms, -1); } catch (const simgrid::TimeoutException& e) { - finished_index = e.value; + finished_index = e.get_value(); status = MSG_TIMEOUT; } catch (const simgrid::CancelException& e) { - finished_index = e.value; + finished_index = e.get_value(); status = MSG_TASK_CANCELED; } catch (const simgrid::NetworkFailureException& e) { - finished_index = e.value; + finished_index = e.get_value(); status = MSG_TRANSFER_FAILURE; } @@ -197,7 +194,7 @@ int MSG_comm_waitany(const_xbt_dynar_t comms) (*comm->task_received)->set_not_used(); } - return finished_index; + return static_cast(finished_index); } /**