Skip to content

Commit

Permalink
comment cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Nov 18, 2023
1 parent 8c12037 commit daa2333
Show file tree
Hide file tree
Showing 49 changed files with 317 additions and 303 deletions.
114 changes: 64 additions & 50 deletions include/wrench/simgrid_S4U_util/S4U_CommPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*
*/

#ifndef WRENCH_S4U_MAILBOX_H
#define WRENCH_S4U_MAILBOX_H
#ifndef WRENCH_S4U_COMMPORT_H
#define WRENCH_S4U_COMMPORT_H


#include <string>
Expand All @@ -25,7 +25,6 @@ namespace wrench {
/** \cond INTERNAL */
/***********************/

//class SimulationMessage;
class S4U_PendingCommunication;

/**
Expand All @@ -35,32 +34,40 @@ namespace wrench {

public:


template<class TMessageType>
std::string get_type_name() {
char const *type_name = typeid(TMessageType).name();
return boost::core::demangle(type_name);
}

/**
* @brief Constructor
*/
S4U_CommPort() {
this->s4u_mb = simgrid::s4u::Mailbox::by_name("tmp" + std::to_string(S4U_CommPort::generateUniqueSequenceNumber()));
this->name = this->s4u_mb->get_name();
auto number = std::to_string(S4U_CommPort::generateUniqueSequenceNumber());
this->s4u_mb = simgrid::s4u::Mailbox::by_name("mb_" + number);
this->s4u_mq = simgrid::s4u::MessageQueue::by_name("mq_" + number);
this->name = "cp_" + number;
}

/**
* @brief Synchronously receive a message from a commport_name
*
* @param error_prefix: any string you wish to prefix the error message with
* @return the message, in a unique_ptr of the type specified. Otherwise throws a runtime_error
*
* @throw std::shared_ptr<NetworkError>
*/
* @brief Synchronously receive a message from a commport_name
*
* @param error_prefix: any string you wish to prefix the error message with
* @return the message, in a unique_ptr of the type specified. Otherwise throws a runtime_error
*
* @throw std::shared_ptr<NetworkError>
*/
template<class TMessageType>
std::unique_ptr<TMessageType> getMessage(const std::string &error_prefix = "") {
auto id = ++messageCounter;
#ifndef NDEBUG
char const *name = typeid(TMessageType).name();
std::string tn = boost::core::demangle(name);
this->templateWaitingLog(tn, id);
// char const *type_name = typeid(TMessageType).name();
// std::string tn = boost::core::demangle(type_name);
auto tn = this->templateWaitingLog(get_type_name<TMessageType>(), id);
#endif


auto message = this->getMessage(false);

if (auto msg = dynamic_cast<TMessageType *>(message.get())) {
Expand All @@ -70,27 +77,30 @@ namespace wrench {
message.release();
return std::unique_ptr<TMessageType>(msg);
} else {
char const *name = typeid(TMessageType).name();
std::string tn = boost::core::demangle(name);
throw std::runtime_error(error_prefix + " Unexpected [" + message->getName() + "] message while waiting for " + tn.c_str() + ". Request ID: " + std::to_string(id));
// char const *type_name = typeid(TMessageType).name();
// std::string tn = boost::core::demangle(type_name);
throw std::runtime_error(error_prefix + " Unexpected [" + message->getName() + "] message while waiting for " +
get_type_name<TMessageType>() + ". Request ID: " + std::to_string(id));
}
}

/**
* @brief Synchronously receive a message from a commport_name
*
* @param error_prefix: any string you wish to prefix the error message with
* @param timeout: a timeout value in seconds (<0 means never timeout)
*
* @return the message, in a unique_ptr of the type specified. Otherwise throws a runtime_error
*
* @throw std::shared_ptr<NetworkError>
*/
* @brief Synchronously receive a message from a commport
*
* @param error_prefix: any string you wish to prefix the error message with
* @param timeout: a timeout value in seconds (<0 means never timeout)
*
* @return the message, in a unique_ptr of the type specified. Otherwise throws a runtime_error
*
* @throw std::shared_ptr<NetworkError>
*/
template<class TMessageType>
std::unique_ptr<TMessageType> getMessage(double timeout, const std::string &error_prefix = "") {
auto id = ++messageCounter;
#ifndef NDEBUG
char const *name = typeid(TMessageType).name();
std::string tn = boost::core::demangle(name);
// char const *type_name = typeid(TMessageType).name();
// std::string tn = boost::core::demangle(type_name);
auto tn = get_type_name<TMessageType>();
this->templateWaitingLog(tn, id);
#endif

Expand All @@ -104,32 +114,36 @@ namespace wrench {
#endif
return std::unique_ptr<TMessageType>(msg);
} else {
char const *name = typeid(TMessageType).name();
std::string tn = boost::core::demangle(name);
throw std::runtime_error(error_prefix + " Unexpected [" + message->getName() + "] message while waiting for " + tn.c_str() + ". Request ID: " + std::to_string(id));
// char const *type_name = typeid(TMessageType).name();
// std::string tn = boost::core::demangle(type_name);
throw std::runtime_error(error_prefix + " Unexpected [" + message->getName() + "] message while waiting for " +
get_type_name<TMessageType>() + ". Request ID: " + std::to_string(id));
}
}

/**
* @brief Synchronously receive a message from a commport_name
*
* @return the message, or nullptr (in which case it's likely a brutal termination)
*
* @throw std::shared_ptr<NetworkError>
*/
* @brief Synchronously receive a message from a commport_name
*
* @return the message, or nullptr (in which case it's likely a brutal termination)
*
* @throw std::shared_ptr<NetworkError>
*/
std::unique_ptr<SimulationMessage> getMessage() {
return getMessage(true);
}

/**
* @brief Synchronously receive a message from a commport_name, with a timeout
*
* @param timeout: a timeout value in seconds (<0 means never timeout)
* @return the message, or nullptr (in which case it's likely a brutal termination)
*
* @throw std::shared_ptr<NetworkError>
*/
* @brief Synchronously receive a message from a commport_name, with a timeout
*
* @param timeout: a timeout value in seconds (<0 means never timeout)
* @return the message, or nullptr (in which case it's likely a brutal termination)
*
* @throw std::shared_ptr<NetworkError>
*/
std::unique_ptr<SimulationMessage> getMessage(double timeout) {
return this->getMessage(timeout, true);
}

void putMessage(SimulationMessage *m);
void dputMessage(SimulationMessage *msg);
std::shared_ptr<S4U_PendingCommunication> iputMessage(SimulationMessage *msg);
Expand All @@ -139,7 +153,6 @@ namespace wrench {

static S4U_CommPort *getTemporaryCommPort();
static void retireTemporaryCommPort(S4U_CommPort *commport);

static void createCommPortPool(unsigned long num_commports);

/**
Expand All @@ -156,13 +169,13 @@ namespace wrench {
* @brief The "not a commport_name" commport_name, to avoid getting answers back when asked
* to prove an "answer commport_name"
*/
static S4U_CommPort *NULL_MAILBOX;
static S4U_CommPort *NULL_COMMPORT;

const std::string get_name() const {
return this->name;
}

const char *get_cname() const {
[[nodiscard]] const char *get_cname() const {
return this->name.c_str();
}

Expand All @@ -171,6 +184,7 @@ namespace wrench {
friend class S4U_PendingCommunication;

simgrid::s4u::Mailbox *s4u_mb;
simgrid::s4u::MessageQueue *s4u_mq;

std::unique_ptr<SimulationMessage> getMessage(bool log);
std::unique_ptr<SimulationMessage> getMessage(double timeout, bool log);
Expand All @@ -194,4 +208,4 @@ namespace wrench {
}// namespace wrench


#endif//WRENCH_S4U_MAILBOX_H
#endif//WRENCH_S4U_COMMPORT_H
2 changes: 1 addition & 1 deletion include/wrench/simgrid_S4U_util/S4U_Daemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@ namespace wrench {
}// namespace wrench


#endif//WRENCH_SIM4U_DAEMONWITHMAILBOX_H
#endif//WRENCH_SIM4U_DAEMON_H
2 changes: 1 addition & 1 deletion include/wrench/simgrid_S4U_util/S4U_DaemonActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ namespace wrench {
}// namespace wrench


#endif//WRENCH_SIM4U_DAEMONWITHMAILBOXACTOR_H
#endif//WRENCH_SIM4U_DAEMONACTOR_H
6 changes: 3 additions & 3 deletions src/wrench/execution_events/ExecutionEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ namespace wrench {

/**
* @brief Block the calling process until a ExecutionEvent is generated
* based on messages received on a commport_name, or until a timeout ooccurs
* based on messages received on a commport, or until a timeout ooccurs
*
* @param commport: the name of the receiving commport_name
* @param commport: the name of the receiving commport
* @param timeout: a timeout value in seconds (-1 means: no timeout)
* @return a workflow execution event (or nullptr in case of a timeout)
*
Expand All @@ -37,7 +37,7 @@ namespace wrench {
*/
std::shared_ptr<ExecutionEvent>
ExecutionEvent::waitForNextExecutionEvent(S4U_CommPort *commport, double timeout) {
// Get the message from the commport_name
// Get the message from the commport
std::shared_ptr<SimulationMessage> message = nullptr;
try {
message = commport->getMessage<SimulationMessage>(timeout);
Expand Down
6 changes: 3 additions & 3 deletions src/wrench/failure_causes/NetworkError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace wrench {
* @param operation_type: NetworkError:OperationType::SENDING or NetworkError::OperationType::RECEIVING or
* NetworkError::OperationType::UNKNOWN
* @param error_type: the error type
* @param commport_name: the name of a commport_name (or "" if unknown)
* @param commport_name: the name of a commport (or "" if unknown)
*/
NetworkError::NetworkError(NetworkError::OperationType operation_type,
NetworkError::ErrorType error_type,
Expand Down Expand Up @@ -64,7 +64,7 @@ namespace wrench {

/**
* @brief Returns the name of the CommPort on which the error occurred
* @return the commport_name name
* @return the commport name
*/
std::string NetworkError::getCommPortName() {
return this->commport_name;
Expand All @@ -87,7 +87,7 @@ namespace wrench {
} else {
error = "link failure, or communication peer died";
}
return "Network error (" + error + ") while " + operation + " commport_name " + this->commport_name;
return "Network error (" + error + ") while " + operation + " commport " + this->commport_name;
}


Expand Down
18 changes: 9 additions & 9 deletions src/wrench/job/Job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ namespace wrench {
}

/**
* @brief Get the "origin" callback commport_name
* @brief Get the "origin" callback commport
*
* @return the next callback commport_name
* @return the next callback commport
*/
S4U_CommPort *Job::getOriginCallbackCommPort() {
return this->originator_commport;
Expand All @@ -75,11 +75,11 @@ namespace wrench {
}

/**
* @brief Get the "next" callback commport_name (returns the
* workflow commport_name if the commport_name stack is empty), and
* @brief Get the "next" callback commport (returns the
* workflow commport if the commport stack is empty), and
* pops it
*
* @return the next callback commport_name
* @return the next callback commport
*/
S4U_CommPort *Job::popCallbackCommPort() {
if (this->callback_commport_stack.empty()) {
Expand All @@ -91,8 +91,8 @@ namespace wrench {
}

/**
* @brief Get the job's "next" callback commport_name, without popping it
* @return the next callback commport_name
* @brief Get the job's "next" callback commport, without popping it
* @return the next callback commport
*/
S4U_CommPort *Job::getCallbackCommPort() {
if (this->callback_commport_stack.empty()) {
Expand All @@ -102,9 +102,9 @@ namespace wrench {
}

/**
* @brief Pushes a callback commport_name
* @brief Pushes a callback commport
*
* @param commport: the commport_name name
* @param commport: the commport name
*/
void Job::pushCallbackCommPort(S4U_CommPort *commport) {
this->callback_commport_stack.push(commport);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace wrench {
* @brief Constructor
*
* @param hostname: the hostname on which the data movement manager is to run
* @param creator_commport: the commport_name of the manager's creator
* @param creator_commport: the commport of the manager's creator
*/
DataMovementManager::DataMovementManager(std::string hostname, S4U_CommPort *creator_commport) : Service(hostname, "data_movement_manager") {
this->creator_commport = creator_commport;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace wrench {
* @brief Constructor
*
* @param hostname: the hostname on which the data movement manager is to run
* @param creator_commport: the commport_name of the manager's creator
* @param creator_commport: the commport of the manager's creator
* @param location: the read location
* @param num_bytes: the number of bytes to read
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace wrench {
* @brief Constructor
*
* @param hostname: the hostname on which the data movement manager is to run
* @param creator_commport: the commport_name of the manager's creator
* @param creator_commport: the commport of the manager's creator
* @param location: the write location
*/
FileWriterThread::FileWriterThread(std::string hostname,
Expand Down
6 changes: 3 additions & 3 deletions src/wrench/managers/job_manager/JobManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace wrench {
* @brief Constructor
*
* @param hostname: the name of host on which the job manager will run
* @param creator_commport: the commport_name of the manager's creator
* @param creator_commport: the commport of the manager's creator
*/
JobManager::JobManager(std::string hostname, S4U_CommPort *creator_commport) : Service(std::move(hostname), "job_manager") {
this->creator_commport = creator_commport;
Expand Down Expand Up @@ -1214,9 +1214,9 @@ namespace wrench {
}

/**
* @brief Return the commport_name of the job manager's creator
* @brief Return the commport of the job manager's creator
*
* @return a commport_name
* @return a CommPort
*/
S4U_CommPort *JobManager::getCreatorCommPort() {
return this->creator_commport;
Expand Down
2 changes: 1 addition & 1 deletion src/wrench/services/Service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ namespace wrench {

WRENCH_INFO("Telling the daemon listening on (%s) to terminate", this->commport->get_cname());

// Send a termination message to the daemon's commport_name - SYNCHRONOUSLY
// Send a termination message to the daemon's commport - SYNCHRONOUSLY
auto ack_commport = S4U_Daemon::getRunningActorRecvCommPort();
std::unique_ptr<SimulationMessage> message = nullptr;
try {
Expand Down
2 changes: 1 addition & 1 deletion src/wrench/services/ServiceMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace wrench {

/**
* @brief Constructor
* @param ack_commport: commport_name to which the DaemonStoppedMessage ack will be sent. No ack will be sent if ack_commport=""
* @param ack_commport: commport to which the DaemonStoppedMessage ack will be sent. No ack will be sent if ack_commport=""
* @param send_failure_notifications: whether the service should send failure notifications before terminating
* @param termination_cause: the termination cause (if failure notifications are sent)
* @param payload: message size in bytes
Expand Down
Loading

0 comments on commit daa2333

Please sign in to comment.