From b57a1fe209ff94b47995645040b209c1cb2641a4 Mon Sep 17 00:00:00 2001 From: Henri Casanova Date: Sat, 18 Nov 2023 14:16:10 -1000 Subject: [PATCH] Code removal --- src/wrench/simgrid_S4U_util/S4U_CommPort.cpp | 22 +++++++------------ .../S4U_PendingCommunication.cpp | 20 ++--------------- 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/src/wrench/simgrid_S4U_util/S4U_CommPort.cpp b/src/wrench/simgrid_S4U_util/S4U_CommPort.cpp index 88f120ffb9..c84964257e 100755 --- a/src/wrench/simgrid_S4U_util/S4U_CommPort.cpp +++ b/src/wrench/simgrid_S4U_util/S4U_CommPort.cpp @@ -76,6 +76,9 @@ namespace wrench { * */ std::unique_ptr S4U_CommPort::getMessage(bool log) { + + return this->getMessage(-1, log); +#if 0 if (this == S4U_CommPort::NULL_COMMPORT) { throw std::invalid_argument("S4U_CommPort::getMessage(): Cannot be called with NULL_COMMPORT"); } @@ -84,7 +87,7 @@ namespace wrench { SimulationMessage *msg; try { // msg = static_cast(commport->get()); - msg = this->s4u_mb->get(); + msg = this->s4u_mb->get(-1); } catch (simgrid::NetworkFailureException &e) { throw ExecutionException(std::make_shared( NetworkError::RECEIVING, NetworkError::FAILURE, this->s4u_mb->get_cname())); @@ -96,6 +99,7 @@ namespace wrench { WRENCH_DEBUG("Received a '%s' message from commport %s", msg->getName().c_str(), this->s4u_mb->get_cname()); return std::unique_ptr(msg); +#endif } /** @@ -113,15 +117,10 @@ namespace wrench { throw std::invalid_argument("S4U_CommPort::getMessage(): Cannot be called with NULL_COMMPORT"); } - if (timeout < 0) { - return this->getMessage(); - } - if (log) WRENCH_DEBUG("Getting a message from commport '%s' with timeout %lf sec", this->s4u_mb->get_cname(), timeout); - wrench::SimulationMessage *msg; + SimulationMessage *msg; try { - // data = commport->get(timeout); msg = this->s4u_mb->get(timeout); } catch (simgrid::NetworkFailureException &e) { throw ExecutionException(std::make_shared( @@ -131,8 +130,6 @@ namespace wrench { NetworkError::RECEIVING, NetworkError::TIMEOUT, this->s4u_mb->get_name())); } - // auto msg = static_cast(data); - #ifdef MESSAGE_MANAGER MessageManager::removeReceivedMessage(this, msg); @@ -195,10 +192,7 @@ namespace wrench { #ifdef MESSAGE_MANAGER MessageManager::manageMessage(this, msg); #endif - //if (msg->payload) this->s4u_mb->put_init(msg, (uint64_t) msg->payload)->detach(); - //else - // commport->put(msg, 0); } /** @@ -222,7 +216,7 @@ namespace wrench { msg->getName().c_str(), msg->payload, this->s4u_mb->get_cname()); - simgrid::s4u::CommPtr comm_ptr = nullptr; + simgrid::s4u::CommPtr comm_ptr; try { #ifdef MESSAGE_MANAGER @@ -256,7 +250,7 @@ namespace wrench { throw std::invalid_argument("S4U_CommPort::igetMessage(): Cannot be called with NULL_COMMPORT"); } - simgrid::s4u::CommPtr comm_ptr = nullptr; + simgrid::s4u::CommPtr comm_ptr; WRENCH_DEBUG("Igetting a message from commport '%s'", this->s4u_mb->get_cname()); diff --git a/src/wrench/simgrid_S4U_util/S4U_PendingCommunication.cpp b/src/wrench/simgrid_S4U_util/S4U_PendingCommunication.cpp index 18649cdde7..6a212ece4a 100755 --- a/src/wrench/simgrid_S4U_util/S4U_PendingCommunication.cpp +++ b/src/wrench/simgrid_S4U_util/S4U_PendingCommunication.cpp @@ -36,23 +36,7 @@ namespace wrench { * @throw std::shared_ptr */ std::unique_ptr S4U_PendingCommunication::wait() { - try { - if (this->comm_ptr->get_state() != simgrid::s4u::Activity::State::FINISHED) { - this->comm_ptr->wait(); - } - } catch (simgrid::NetworkFailureException &e) { - if (this->operation_type == S4U_PendingCommunication::OperationType::SENDING) { - throw ExecutionException(std::make_shared( - NetworkError::OperationType::SENDING, NetworkError::FAILURE, this->commport->s4u_mb->get_name())); - } else { - throw ExecutionException(std::make_shared( - NetworkError::OperationType::RECEIVING, NetworkError::FAILURE, this->commport->s4u_mb->get_name())); - } - } -#ifdef MESSAGE_MANAGER - MessageManager::removeReceivedMessage(this->commport, this->simulation_message.get()); -#endif - return std::move(this->simulation_message); + return this->wait(-1); } /** @@ -66,7 +50,7 @@ namespace wrench { std::unique_ptr S4U_PendingCommunication::wait(double timeout) { try { if (this->comm_ptr->get_state() != simgrid::s4u::Activity::State::FINISHED) { - this->comm_ptr->wait_until(Simulation::getCurrentSimulatedDate() + timeout); + this->comm_ptr->wait_for(timeout); } } catch (simgrid::NetworkFailureException &e) { if (this->operation_type == S4U_PendingCommunication::OperationType::SENDING) {