X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/dc1369e2055686dde3d178efb2001dbad8972d54..0148c7da36c56897bde72a1d050d288b87762cfc:/src/msg/msg_comm.cpp diff --git a/src/msg/msg_comm.cpp b/src/msg/msg_comm.cpp index 28db1e5402..8490f780f0 100644 --- a/src/msg/msg_comm.cpp +++ b/src/msg/msg_comm.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2004-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. */ @@ -13,8 +13,6 @@ #include "src/instr/instr_private.hpp" #include "src/msg/msg_private.hpp" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_comm, msg, "Logging specific to MSG (comm)"); - namespace simgrid { namespace msg { @@ -28,19 +26,15 @@ bool Comm::test() /* I am the receiver */ (*task_received)->set_not_used(); } - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutException&) { status_ = MSG_TIMEOUT; finished = true; - } catch (simgrid::CancelException& e) { + } catch (const simgrid::CancelException&) { status_ = MSG_TASK_CANCELED; finished = true; - } catch (xbt_ex& e) { - if (e.category == network_error) { - status_ = MSG_TRANSFER_FAILURE; - finished = true; - } else { - throw; - } + } catch (const simgrid::NetworkFailureException&) { + status_ = MSG_TRANSFER_FAILURE; + finished = true; } return finished; @@ -56,15 +50,12 @@ msg_error_t Comm::wait_for(double timeout) } /* FIXME: these functions are not traceable */ - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutException&) { status_ = MSG_TIMEOUT; - } catch (simgrid::CancelException& e) { + } catch (const simgrid::CancelException&) { status_ = MSG_TASK_CANCELED; - } catch (xbt_ex& e) { - if (e.category == network_error) - status_ = MSG_TRANSFER_FAILURE; - else - throw; + } catch (const simgrid::NetworkFailureException&) { + status_ = MSG_TRANSFER_FAILURE; } return status_; @@ -91,7 +82,7 @@ int MSG_comm_test(msg_comm_t comm) * @return the position of the finished communication if any * (but it may have failed, use MSG_comm_get_status() to know its status), or -1 if none is finished */ -int MSG_comm_testany(xbt_dynar_t comms) +int MSG_comm_testany(const_xbt_dynar_t comms) { int finished_index = -1; @@ -107,15 +98,13 @@ int MSG_comm_testany(xbt_dynar_t comms) msg_error_t status = MSG_OK; try { finished_index = simcall_comm_testany(s_comms.data(), s_comms.size()); - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutException& e) { finished_index = e.value; status = MSG_TIMEOUT; - } catch (simgrid::CancelException& e) { + } catch (const simgrid::CancelException& e) { finished_index = e.value; status = MSG_TASK_CANCELED; - } catch (xbt_ex& e) { - if (e.category != network_error) - throw; + } catch (const simgrid::NetworkFailureException& e) { finished_index = e.value; status = MSG_TRANSFER_FAILURE; } @@ -135,7 +124,7 @@ int MSG_comm_testany(xbt_dynar_t comms) } /** @brief Destroys the provided communication. */ -void MSG_comm_destroy(msg_comm_t comm) +void MSG_comm_destroy(const_msg_comm_t comm) { delete comm; } @@ -153,7 +142,7 @@ msg_error_t MSG_comm_wait(msg_comm_t comm, double timeout) return comm->wait_for(timeout); } -/** @brief This function is called by a sender and permit to wait for each communication +/** @brief This function is called by a sender and permits waiting for each communication * * @param comm a vector of communication * @param nb_elem is the size of the comm vector @@ -170,7 +159,7 @@ void MSG_comm_waitall(msg_comm_t* comm, int nb_elem, double timeout) * @return the position of the first finished communication * (but it may have failed, use MSG_comm_get_status() to know its status) */ -int MSG_comm_waitany(xbt_dynar_t comms) +int MSG_comm_waitany(const_xbt_dynar_t comms) { int finished_index = -1; @@ -186,19 +175,15 @@ int MSG_comm_waitany(xbt_dynar_t comms) msg_error_t status = MSG_OK; try { finished_index = simcall_comm_waitany(s_comms.data(), s_comms.size(), -1); - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutException& e) { finished_index = e.value; status = MSG_TIMEOUT; - } catch (simgrid::CancelException& e) { + } catch (const simgrid::CancelException& e) { finished_index = e.value; status = MSG_TASK_CANCELED; - } catch (xbt_ex& e) { - if (e.category == network_error) { - finished_index = e.value; - status = MSG_TRANSFER_FAILURE; - } else { - throw; - } + } catch (const simgrid::NetworkFailureException& e) { + finished_index = e.value; + status = MSG_TRANSFER_FAILURE; } xbt_assert(finished_index != -1, "WaitAny returned -1"); @@ -220,9 +205,8 @@ int MSG_comm_waitany(xbt_dynar_t comms) * @param comm a finished communication * @return the status of the communication, or #MSG_OK if no error occurred during the communication */ -msg_error_t MSG_comm_get_status(msg_comm_t comm) +msg_error_t MSG_comm_get_status(const_msg_comm_t comm) { - return comm->get_status(); } @@ -231,27 +215,9 @@ msg_error_t MSG_comm_get_status(msg_comm_t comm) * @param comm the communication where to get the task * @return the task from the communication */ -msg_task_t MSG_comm_get_task(msg_comm_t comm) +msg_task_t MSG_comm_get_task(const_msg_comm_t comm) { xbt_assert(comm, "Invalid parameter"); return comm->task_received ? *comm->task_received : comm->task_sent; } - -/** - * @brief This function is called by SIMIX in kernel mode to copy the data of a comm. - * @param comm the comm - * @param buff the data copied - * @param buff_size size of the buffer - */ -// deprecated but used by MSG_set_copy_callback. Should be removed in v325 -void MSG_comm_copy_data_from_SIMIX(simgrid::kernel::activity::CommImpl* comm, void* buff, size_t buff_size) -{ - SIMIX_comm_copy_pointer_callback(comm, buff, buff_size); - - // notify the user callback if any - if (msg_global->task_copy_callback) { - msg_task_t task = static_cast(buff); - msg_global->task_copy_callback(task, comm->src_actor_->ciface(), comm->dst_actor_->ciface()); - } -}