Skip to content

Commit

Permalink
Code removal
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Nov 19, 2023
1 parent 6a01cb0 commit b57a1fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 32 deletions.
22 changes: 8 additions & 14 deletions src/wrench/simgrid_S4U_util/S4U_CommPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ namespace wrench {
*
*/
std::unique_ptr<SimulationMessage> 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");
}
Expand All @@ -84,7 +87,7 @@ namespace wrench {
SimulationMessage *msg;
try {
// msg = static_cast<SimulationMessage *>(commport->get());
msg = this->s4u_mb->get<SimulationMessage>();
msg = this->s4u_mb->get<SimulationMessage>(-1);
} catch (simgrid::NetworkFailureException &e) {
throw ExecutionException(std::make_shared<NetworkError>(
NetworkError::RECEIVING, NetworkError::FAILURE, this->s4u_mb->get_cname()));
Expand All @@ -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<SimulationMessage>(msg);
#endif
}

/**
Expand All @@ -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<SimulationMessage>(timeout);
} catch (simgrid::NetworkFailureException &e) {
throw ExecutionException(std::make_shared<NetworkError>(
Expand All @@ -131,8 +130,6 @@ namespace wrench {
NetworkError::RECEIVING, NetworkError::TIMEOUT, this->s4u_mb->get_name()));
}

// auto msg = static_cast<SimulationMessage *>(data);


#ifdef MESSAGE_MANAGER
MessageManager::removeReceivedMessage(this, msg);
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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
Expand Down Expand Up @@ -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());

Expand Down
20 changes: 2 additions & 18 deletions src/wrench/simgrid_S4U_util/S4U_PendingCommunication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,7 @@ namespace wrench {
* @throw std::shared_ptr<NetworkError>
*/
std::unique_ptr<SimulationMessage> 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>(
NetworkError::OperationType::SENDING, NetworkError::FAILURE, this->commport->s4u_mb->get_name()));
} else {
throw ExecutionException(std::make_shared<NetworkError>(
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);
}

/**
Expand All @@ -66,7 +50,7 @@ namespace wrench {
std::unique_ptr<SimulationMessage> 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) {
Expand Down

0 comments on commit b57a1fe

Please sign in to comment.