Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid into...
[simgrid.git] / examples / msg / kademlia / task.c
index 1230818..770cd62 100644 (file)
@@ -5,7 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 #include "task.h"
 #include "answer.h"
- XBT_LOG_NEW_DEFAULT_CATEGORY(msg_kademlia_task,
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_kademlia_task,
                              "Messages specific for this msg example");
 /**
   * Creates a new "find node" task
   * @param destination_id the id the sender is trying to find
   * @param hostname the hostname of the node, for logging purposes
   */
-msg_task_t task_new_find_node(unsigned int sender_id, unsigned int destination_id, char *mailbox, const char *hostname) {
+msg_task_t task_new_find_node(unsigned int sender_id,
+                              unsigned int destination_id, char *mailbox,
+                              const char *hostname)
+{
 
-  task_data_t data = xbt_new(s_task_data_t,1);
+  task_data_t data = xbt_new(s_task_data_t, 1);
 
   data->type = TASK_FIND_NODE;
   data->sender_id = sender_id;
@@ -25,10 +28,11 @@ msg_task_t task_new_find_node(unsigned int sender_id, unsigned int destination_i
   data->issuer_host_name = hostname;
 
 
-  msg_task_t task = MSG_task_create(NULL,COMP_SIZE,COMM_SIZE,data);  
-  
+  msg_task_t task = MSG_task_create(NULL, COMP_SIZE, COMM_SIZE, data);
+
   return task;
 }
+
 /**
   * Creates a new "answer to find node" task
   *  @param sender_id the node who sent the task
@@ -37,30 +41,37 @@ msg_task_t task_new_find_node(unsigned int sender_id, unsigned int destination_i
   *  @param mailbox The mailbox of the sender
   *  @param hostname sender hostname
   */
-msg_task_t task_new_find_node_answer(unsigned int sender_id, unsigned int destination_id, answer_t answer, char *mailbox, const char *hostname) {
+msg_task_t task_new_find_node_answer(unsigned int sender_id,
+                                     unsigned int destination_id,
+                                     answer_t answer, char *mailbox,
+                                     const char *hostname)
+{
+
+  task_data_t data = xbt_new(s_task_data_t, 1);
 
-  task_data_t data = xbt_new(s_task_data_t,1);
-  
   data->type = TASK_FIND_NODE_ANSWER;
   data->sender_id = sender_id;
   data->destination_id = destination_id;
   data->answer = answer;
   data->answer_to = mailbox;
-  data->issuer_host_name = hostname;      
+  data->issuer_host_name = hostname;
+
+  msg_task_t task = MSG_task_create(NULL, COMP_SIZE, COMM_SIZE, data);
 
-  msg_task_t task = MSG_task_create(NULL,COMP_SIZE,COMM_SIZE,data);  
-  
   return task;
 }
+
 /**
   * Creates a new "ping" task
   * @param sender_id : sender node identifier
   * @param mailbox : mailbox where we should respond
   * @param hostname : hostname of the sender, for debugging purposes
   */
-msg_task_t task_new_ping(unsigned int sender_id, char *mailbox, const char *hostname) {
+msg_task_t task_new_ping(unsigned int sender_id, char *mailbox,
+                         const char *hostname)
+{
 
-  task_data_t data = xbt_new(s_task_data_t,1);
+  task_data_t data = xbt_new(s_task_data_t, 1);
 
   data->type = TASK_PING;
   data->sender_id = sender_id;
@@ -69,19 +80,22 @@ msg_task_t task_new_ping(unsigned int sender_id, char *mailbox, const char *host
   data->answer_to = mailbox;
   data->issuer_host_name = hostname;
 
-  msg_task_t task = MSG_task_create(NULL,COMP_SIZE,COMM_SIZE,data);  
-  
+  msg_task_t task = MSG_task_create(NULL, COMP_SIZE, COMM_SIZE, data);
+
   return task;
 }
+
 /**
   * Creates a new "ping answer" task
   * @param sender_id : sender node identifier
   * @param mailbox : mailbox of the sender
   * @param hostname : hostname of the sender, for debugging purposes
   */
-msg_task_t task_new_ping_answer(unsigned int sender_id, char *mailbox, const char *hostname) {
+msg_task_t task_new_ping_answer(unsigned int sender_id, char *mailbox,
+                                const char *hostname)
+{
 
-  task_data_t data = xbt_new(s_task_data_t,1);
+  task_data_t data = xbt_new(s_task_data_t, 1);
 
   data->type = TASK_PING_ANSWER;
   data->sender_id = sender_id;
@@ -90,31 +104,35 @@ msg_task_t task_new_ping_answer(unsigned int sender_id, char *mailbox, const cha
   data->answer_to = mailbox;
   data->issuer_host_name = hostname;
 
-  msg_task_t task = MSG_task_create(NULL,COMP_SIZE,COMM_SIZE,data);  
-  
+  msg_task_t task = MSG_task_create(NULL, COMP_SIZE, COMM_SIZE, data);
+
   return task;
 }
+
 /**
   * Destroys a task and its data
   * @param task the task that'll be destroyed
   */
-void task_free(msg_task_t task) {
-  xbt_assert( (task != NULL), "Tried to free a NULL task");
+void task_free(msg_task_t task)
+{
+  xbt_assert((task != NULL), "Tried to free a NULL task");
 
   task_data_t data = MSG_task_get_data(task);
-    
+
   if (data->answer) {
     answer_free(data->answer);
   }
   xbt_free(data);
-  
+
   MSG_task_destroy(task);
 
 }
+
 /**
   * Destroys a task and its data (taking a void* pointer
   * @param task The task that'll be destroyed
   */
-void task_free_v(void *task) {
+void task_free_v(void *task)
+{
   task_free(task);
 }