From 9853c047276b618315bd3f064c1f13c3d3ccd771 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 2 Jul 2019 16:14:38 +0200 Subject: [PATCH] Rename simgrid::TimeoutError to simgrid::TimeoutException. --- ChangeLog | 3 +++ doc/doxygen/uhood_switch.doc | 2 +- examples/s4u/app-bittorrent/s4u-peer.cpp | 4 ++-- examples/s4u/dht-chord/s4u-dht-chord-node.cpp | 16 ++++++++-------- examples/s4u/exec-ptask/s4u-exec-ptask.cpp | 2 +- .../platform-failures/s4u-platform-failures.cpp | 4 ++-- include/simgrid/Exception.hpp | 6 ++++-- src/kernel/activity/CommImpl.cpp | 4 ++-- src/kernel/activity/ExecImpl.cpp | 2 +- src/msg/msg_comm.cpp | 8 ++++---- src/msg/msg_task.cpp | 6 +++--- 11 files changed, 31 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6c43d5f1a2..7659918a0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ Documentation: - Nicer introduction page. - Move Java as a subtree of MSG. +General: + - Rename simgrid::TimeoutError to simgrid::TimeoutException. + XBT: - Drop xbt_dynar_sort_strings(). diff --git a/doc/doxygen/uhood_switch.doc b/doc/doxygen/uhood_switch.doc index f9b3ad14e4..b26b31590c 100644 --- a/doc/doxygen/uhood_switch.doc +++ b/doc/doxygen/uhood_switch.doc @@ -708,7 +708,7 @@ std::cv_status ConditionVariable::wait_for( simcall_cond_wait_timeout(cond_, lock.mutex()->mutex_, timeout); return std::cv_status::no_timeout; } - catch (const simgrid::TimeoutError& e) { + catch (const simgrid::TimeoutException& e) { // If the exception was a timeout, we have to take the lock again: try { lock.mutex()->lock(); diff --git a/examples/s4u/app-bittorrent/s4u-peer.cpp b/examples/s4u/app-bittorrent/s4u-peer.cpp index 6d133cc240..ff9a09476c 100644 --- a/examples/s4u/app-bittorrent/s4u-peer.cpp +++ b/examples/s4u/app-bittorrent/s4u-peer.cpp @@ -84,7 +84,7 @@ bool Peer::getPeersFromTracker() try { XBT_DEBUG("Sending a peer request to the tracker."); tracker_mailbox->put(peer_request, TRACKER_COMM_SIZE, GET_PEERS_TIMEOUT); - } catch (const simgrid::TimeoutError&) { + } catch (const simgrid::TimeoutException&) { XBT_DEBUG("Timeout expired when requesting peers to tracker"); delete peer_request; return false; @@ -97,7 +97,7 @@ bool Peer::getPeersFromTracker() if (id != peer_id) connected_peers.emplace(peer_id, Connection(peer_id)); delete answer; - } catch (const simgrid::TimeoutError&) { + } catch (const simgrid::TimeoutException&) { XBT_DEBUG("Timeout expired when requesting peers to tracker"); return false; } diff --git a/examples/s4u/dht-chord/s4u-dht-chord-node.cpp b/examples/s4u/dht-chord/s4u-dht-chord-node.cpp index e1d3c23103..9ad0c03570 100644 --- a/examples/s4u/dht-chord/s4u-dht-chord-node.cpp +++ b/examples/s4u/dht-chord/s4u-dht-chord-node.cpp @@ -110,7 +110,7 @@ void Node::notifyAndQuit() XBT_DEBUG("Sending a 'PREDECESSOR_LEAVING' to my successor %d", fingers_[0]); try { simgrid::s4u::Mailbox::by_name(std::to_string(fingers_[0]))->put(pred_msg, 10, timeout); - } catch (const simgrid::TimeoutError&) { + } catch (const simgrid::TimeoutException&) { XBT_DEBUG("Timeout expired when sending a 'PREDECESSOR_LEAVING' to my successor %d", fingers_[0]); delete pred_msg; } @@ -124,7 +124,7 @@ void Node::notifyAndQuit() try { simgrid::s4u::Mailbox::by_name(std::to_string(pred_id_))->put(succ_msg, 10, timeout); - } catch (const simgrid::TimeoutError&) { + } catch (const simgrid::TimeoutException&) { XBT_DEBUG("Timeout expired when sending a 'SUCCESSOR_LEAVING' to my predecessor %d", pred_id_); delete succ_msg; } @@ -214,7 +214,7 @@ void Node::checkPredecessor() XBT_DEBUG("Sending a 'Predecessor Alive' request to my predecessor %d", pred_id_); try { mailbox->put(message, 10, timeout); - } catch (const simgrid::TimeoutError&) { + } catch (const simgrid::TimeoutException&) { XBT_DEBUG("Failed to send the 'Predecessor Alive' request to %d", pred_id_); delete message; return; @@ -229,7 +229,7 @@ void Node::checkPredecessor() comm->wait_for(timeout); XBT_DEBUG("Received the answer to my 'Predecessor Alive': my predecessor %d is alive", pred_id_); delete static_cast(data); - } catch (const simgrid::TimeoutError&) { + } catch (const simgrid::TimeoutException&) { XBT_DEBUG("Failed to receive the answer to my 'Predecessor Alive' request"); pred_id_ = -1; } @@ -255,7 +255,7 @@ int Node::remoteGetPredecessor(int ask_to) XBT_DEBUG("Sending a 'Get Predecessor' request to %d", ask_to); try { mailbox->put(message, 10, timeout); - } catch (const simgrid::TimeoutError&) { + } catch (const simgrid::TimeoutException&) { XBT_DEBUG("Failed to send the 'Get Predecessor' request to %d", ask_to); delete message; return predecessor_id; @@ -273,7 +273,7 @@ int Node::remoteGetPredecessor(int ask_to) answer->answer_id); predecessor_id = answer->answer_id; delete answer; - } catch (const simgrid::TimeoutError&) { + } catch (const simgrid::TimeoutException&) { XBT_DEBUG("Failed to receive the answer to my 'Get Predecessor' request"); delete static_cast(data); } @@ -327,7 +327,7 @@ int Node::remoteFindSuccessor(int ask_to, int id) XBT_DEBUG("Sending a 'Find Successor' request to %d for id %d", ask_to, id); try { mailbox->put(message, 10, timeout); - } catch (const simgrid::TimeoutError&) { + } catch (const simgrid::TimeoutException&) { XBT_DEBUG("Failed to send the 'Find Successor' request to %d for id %d", ask_to, id_); delete message; return successor; @@ -343,7 +343,7 @@ int Node::remoteFindSuccessor(int ask_to, int id) answer->request_id, id_, answer->answer_id); successor = answer->answer_id; delete answer; - } catch (const simgrid::TimeoutError&) { + } catch (const simgrid::TimeoutException&) { XBT_DEBUG("Failed to receive the answer to my 'Find Successor' request"); delete static_cast(data); } diff --git a/examples/s4u/exec-ptask/s4u-exec-ptask.cpp b/examples/s4u/exec-ptask/s4u-exec-ptask.cpp index 9759607a31..146753eb11 100644 --- a/examples/s4u/exec-ptask/s4u-exec-ptask.cpp +++ b/examples/s4u/exec-ptask/s4u-exec-ptask.cpp @@ -55,7 +55,7 @@ static void runner() simgrid::s4u::this_actor::parallel_execute(hosts, computation_amounts, communication_amounts, 10.0 /* timeout (in seconds)*/); xbt_die("Woops, this did not timeout as expected... Please report that bug."); - } catch (const simgrid::TimeoutError&) { + } catch (const simgrid::TimeoutException&) { XBT_INFO("Caught the expected timeout exception."); } diff --git a/examples/s4u/platform-failures/s4u-platform-failures.cpp b/examples/s4u/platform-failures/s4u-platform-failures.cpp index b8004c66b6..0c5bf2d606 100644 --- a/examples/s4u/platform-failures/s4u-platform-failures.cpp +++ b/examples/s4u/platform-failures/s4u-platform-failures.cpp @@ -41,7 +41,7 @@ static int master(int argc, char* argv[]) XBT_INFO("Send a message to %s", mailbox->get_cname()); mailbox->put(payload, comm_size, 10.0); XBT_INFO("Send to %s completed", mailbox->get_cname()); - } catch (const simgrid::TimeoutError&) { + } catch (const simgrid::TimeoutException&) { delete payload; XBT_INFO("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", mailbox->get_cname()); } catch (const simgrid::NetworkFailureException&) { @@ -57,7 +57,7 @@ static int master(int argc, char* argv[]) double* payload = new double(-1.0); try { mailbox->put(payload, 0, 1.0); - } catch (const simgrid::TimeoutError&) { + } catch (const simgrid::TimeoutException&) { delete payload; XBT_INFO("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", mailbox->get_cname()); } catch (const simgrid::NetworkFailureException&) { diff --git a/include/simgrid/Exception.hpp b/include/simgrid/Exception.hpp index 200eb19cdc..e0dc7b4d06 100644 --- a/include/simgrid/Exception.hpp +++ b/include/simgrid/Exception.hpp @@ -93,14 +93,16 @@ private: }; /** Exception raised when a timeout elapsed */ -class TimeoutError : public Exception { +class TimeoutException : public Exception { public: - TimeoutError(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message) + TimeoutException(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message) : Exception(std::move(throwpoint), std::move(message)) { } }; +XBT_ATTRIB_DEPRECATED_v327("Please use simgrid::TimeoutException") typedef TimeoutException TimeoutError; + /** Exception raised when a host fails */ class HostFailureException : public Exception { public: diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index 9031e8312c..4020b9c22f 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -617,12 +617,12 @@ void CommImpl::finish() case SIMIX_SRC_TIMEOUT: simcall->issuer->exception_ = std::make_exception_ptr( - simgrid::TimeoutError(XBT_THROW_POINT, "Communication timeouted because of the sender")); + simgrid::TimeoutException(XBT_THROW_POINT, "Communication timeouted because of the sender")); break; case SIMIX_DST_TIMEOUT: simcall->issuer->exception_ = std::make_exception_ptr( - simgrid::TimeoutError(XBT_THROW_POINT, "Communication timeouted because of the receiver")); + simgrid::TimeoutException(XBT_THROW_POINT, "Communication timeouted because of the receiver")); break; case SIMIX_SRC_HOST_FAILURE: diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index 18c816b52c..b7ed2435fa 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -269,7 +269,7 @@ void ExecImpl::finish() case SIMIX_TIMEOUT: XBT_DEBUG("ExecImpl::finish(): execution timeouted"); - simcall->issuer->exception_ = std::make_exception_ptr(simgrid::TimeoutError(XBT_THROW_POINT, "Timeouted")); + simcall->issuer->exception_ = std::make_exception_ptr(simgrid::TimeoutException(XBT_THROW_POINT, "Timeouted")); break; default: diff --git a/src/msg/msg_comm.cpp b/src/msg/msg_comm.cpp index fcd867ca08..1ecb43d926 100644 --- a/src/msg/msg_comm.cpp +++ b/src/msg/msg_comm.cpp @@ -28,7 +28,7 @@ bool Comm::test() /* I am the receiver */ (*task_received)->set_not_used(); } - } catch (const simgrid::TimeoutError&) { + } catch (const simgrid::TimeoutException&) { status_ = MSG_TIMEOUT; finished = true; } catch (const simgrid::CancelException&) { @@ -52,7 +52,7 @@ msg_error_t Comm::wait_for(double timeout) } /* FIXME: these functions are not traceable */ - } catch (const simgrid::TimeoutError&) { + } catch (const simgrid::TimeoutException&) { status_ = MSG_TIMEOUT; } catch (const simgrid::CancelException&) { status_ = MSG_TASK_CANCELED; @@ -100,7 +100,7 @@ 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 (const simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutException& e) { finished_index = e.value; status = MSG_TIMEOUT; } catch (const simgrid::CancelException& e) { @@ -177,7 +177,7 @@ 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 (const simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutException& e) { finished_index = e.value; status = MSG_TIMEOUT; } catch (const simgrid::CancelException& e) { diff --git a/src/msg/msg_task.cpp b/src/msg/msg_task.cpp index 7284a20a48..bbff07e519 100644 --- a/src/msg/msg_task.cpp +++ b/src/msg/msg_task.cpp @@ -83,7 +83,7 @@ msg_error_t Task::execute() XBT_DEBUG("Execution task '%s' finished", get_cname()); } catch (const HostFailureException&) { status = MSG_HOST_FAILURE; - } catch (const TimeoutError&) { + } catch (const TimeoutException&) { status = MSG_TIMEOUT; } catch (const CancelException&) { status = MSG_TASK_CANCELED; @@ -133,7 +133,7 @@ msg_error_t Task::send(const std::string& alias, double timeout) s4u::CommPtr s4u_comm = send_async(alias, nullptr, false); comm = s4u_comm; comm->wait_for(timeout); - } catch (const simgrid::TimeoutError&) { + } catch (const simgrid::TimeoutException&) { ret = MSG_TIMEOUT; } catch (const simgrid::CancelException&) { ret = MSG_HOST_FAILURE; @@ -623,7 +623,7 @@ msg_error_t MSG_task_receive_ext_bounded(msg_task_t* task, const char* alias, do (*task)->set_not_used(); } catch (const simgrid::HostFailureException&) { ret = MSG_HOST_FAILURE; - } catch (const simgrid::TimeoutError&) { + } catch (const simgrid::TimeoutException&) { ret = MSG_TIMEOUT; } catch (const simgrid::CancelException&) { ret = MSG_TASK_CANCELED; -- 2.20.1