Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Return action state on SIMIX_req_host_execution_wait().
[simgrid.git] / src / simix / smx_user.c
index 3d1f880..91921ef 100644 (file)
@@ -1,6 +1,14 @@
 #include "private.h"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
+
+static const char* request_names[] = {
+#undef SIMIX_REQ_ENUM_ELEMENT
+#define SIMIX_REQ_ENUM_ELEMENT(x) #x /* generate strings from the enumeration values */
+SIMIX_REQ_LIST
+#undef SIMIX_REQ_ENUM_ELEMENT
+};
+
 /**
  * \brief Returns a host given its name.
  *
@@ -142,7 +150,8 @@ void SIMIX_req_host_set_data(smx_host_t host, void *data)
  * \return A new SIMIX execution action
  */
 smx_action_t SIMIX_req_host_execute(const char *name, smx_host_t host,
-                                double computation_amount)
+                                    double computation_amount,
+                                    double priority)
 {
   smx_req_t req = SIMIX_req_mine();
 
@@ -150,6 +159,7 @@ smx_action_t SIMIX_req_host_execute(const char *name, smx_host_t host,
   req->host_execute.name = name;
   req->host_execute.host = host;
   req->host_execute.computation_amount = computation_amount;
+  req->host_execute.priority = priority;
   SIMIX_request_push();
   return req->host_execute.result;
 }
@@ -273,13 +283,14 @@ void SIMIX_req_host_execution_set_priority(smx_action_t execution, double priori
  *
  * \param execution The execution action
  */
-void SIMIX_req_host_execution_wait(smx_action_t execution)
+e_smx_state_t SIMIX_req_host_execution_wait(smx_action_t execution)
 {
   smx_req_t req = SIMIX_req_mine();
 
   req->call = REQ_HOST_EXECUTION_WAIT;
   req->host_execution_wait.execution = execution;
   SIMIX_request_push();
+  return req->host_execution_wait.result;
 }
 
 /**
@@ -553,6 +564,7 @@ void SIMIX_req_rdv_destroy(smx_rdv_t rdv)
 
 smx_rdv_t SIMIX_req_rdv_get_by_name(const char *name)
 {
+  xbt_assert0(name != NULL, "Invalid parameter for SIMIX_req_rdv_get_by_name (name is NULL)");
   smx_req_t req = SIMIX_req_mine();
 
   req->call = REQ_RDV_GEY_BY_NAME;
@@ -700,6 +712,10 @@ void SIMIX_req_comm_wait(smx_action_t comm, double timeout)
  */
 void SIMIX_req_set_category(smx_action_t action, const char *category)
 {
+  if (category == NULL) {
+    return;
+  }
+
   smx_req_t req = SIMIX_req_mine();
 
   req->call = REQ_SET_CATEGORY;
@@ -1035,6 +1051,9 @@ int SIMIX_req_sem_get_capacity(smx_sem_t sem)
   SIMIX_request_push();
   return req->sem_get_capacity.result;
 }
+/* ************************************************************************** */
 
-
-
+/** @brief returns a printable string representing the request kind */
+const char *SIMIX_request_name(int kind) {
+  return request_names[kind];
+}