Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill a redundent oldish API to the activity refcounting
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 30 May 2017 09:36:53 +0000 (11:36 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 30 May 2017 09:36:53 +0000 (11:36 +0200)
include/simgrid/simix.h
src/kernel/activity/CommImpl.cpp
src/msg/msg_gos.cpp
src/s4u/s4u_comm.cpp
src/simix/ActorImpl.cpp
src/simix/smx_network.cpp

index 78dbe75..7f2d4e7 100644 (file)
@@ -226,8 +226,6 @@ XBT_PUBLIC(smx_activity_t) SIMIX_comm_get_send_match(smx_mailbox_t mbox, int (*m
 XBT_PUBLIC(int) SIMIX_comm_has_send_match(smx_mailbox_t mbox, int (*match_fun)(void*, void*), void* data);
 XBT_PUBLIC(int) SIMIX_comm_has_recv_match(smx_mailbox_t mbox, int (*match_fun)(void*, void*), void* data);
 XBT_PUBLIC(void) SIMIX_comm_finish(smx_activity_t synchro);
 XBT_PUBLIC(int) SIMIX_comm_has_send_match(smx_mailbox_t mbox, int (*match_fun)(void*, void*), void* data);
 XBT_PUBLIC(int) SIMIX_comm_has_recv_match(smx_mailbox_t mbox, int (*match_fun)(void*, void*), void* data);
 XBT_PUBLIC(void) SIMIX_comm_finish(smx_activity_t synchro);
-XBT_PUBLIC(smx_activity_t) SIMIX_comm_ref(smx_activity_t comm);
-XBT_PUBLIC(void) SIMIX_comm_unref(smx_activity_t comm);
 
 /******************************************************************************/
 /*                            SIMIX simcalls                                  */
 
 /******************************************************************************/
 /*                            SIMIX simcalls                                  */
index 58182ea..85ccbea 100644 (file)
@@ -62,7 +62,7 @@ void simgrid::kernel::activity::CommImpl::cancel()
   if (state == SIMIX_WAITING) {
     mbox->remove(this);
     state = SIMIX_CANCELED;
   if (state == SIMIX_WAITING) {
     mbox->remove(this);
     state = SIMIX_CANCELED;
-    SIMIX_comm_unref(this);
+    this->unref();
   } else if (not MC_is_active() /* when running the MC there are no surf actions */
              && not MC_record_replay_is_active() && (state == SIMIX_READY || state == SIMIX_RUNNING)) {
 
   } else if (not MC_is_active() /* when running the MC there are no surf actions */
              && not MC_record_replay_is_active() && (state == SIMIX_READY || state == SIMIX_RUNNING)) {
 
@@ -124,6 +124,6 @@ void simgrid::kernel::activity::CommImpl::post()
   /* if there are simcalls associated with the synchro, then answer them */
   if (not simcalls.empty()) {
     SIMIX_comm_finish(this);
   /* if there are simcalls associated with the synchro, then answer them */
   if (not simcalls.empty()) {
     SIMIX_comm_finish(this);
-    SIMIX_comm_unref(this);
+    this->unref();
   }
 }
   }
 }
index 3f416bc..306af43 100644 (file)
@@ -270,7 +270,6 @@ msg_error_t MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, d
     simcall_comm_recv(MSG_process_self()->getImpl(), mailbox->getImpl(), task, nullptr, nullptr, nullptr, nullptr, timeout, rate);
     XBT_DEBUG("Got task %s from %s",(*task)->name,mailbox->name());
     (*task)->simdata->setNotUsed();
     simcall_comm_recv(MSG_process_self()->getImpl(), mailbox->getImpl(), task, nullptr, nullptr, nullptr, nullptr, timeout, rate);
     XBT_DEBUG("Got task %s from %s",(*task)->name,mailbox->name());
     (*task)->simdata->setNotUsed();
-    SIMIX_comm_unref((*task)->simdata->comm);
   }
   catch (xbt_ex& e) {
     switch (e.category) {
   }
   catch (xbt_ex& e) {
     switch (e.category) {
@@ -490,7 +489,7 @@ int MSG_comm_test(msg_comm_t comm)
     if (finished && comm->task_received != nullptr) {
       /* I am the receiver */
       (*comm->task_received)->simdata->setNotUsed();
     if (finished && comm->task_received != nullptr) {
       /* I am the receiver */
       (*comm->task_received)->simdata->setNotUsed();
-      SIMIX_comm_unref(comm->s_comm);
+      comm->s_comm->unref();
     }
   }
   catch (xbt_ex& e) {
     }
   }
   catch (xbt_ex& e) {
@@ -558,7 +557,7 @@ int MSG_comm_testany(xbt_dynar_t comms)
     if (status == MSG_OK && comm->task_received != nullptr) {
       /* I am the receiver */
       (*comm->task_received)->simdata->setNotUsed();
     if (status == MSG_OK && comm->task_received != nullptr) {
       /* I am the receiver */
       (*comm->task_received)->simdata->setNotUsed();
-      SIMIX_comm_unref(comm->s_comm);
+      comm->s_comm->unref();
     }
   }
 
     }
   }
 
@@ -587,7 +586,7 @@ msg_error_t MSG_comm_wait(msg_comm_t comm, double timeout)
 {
   try {
     simcall_comm_wait(comm->s_comm, timeout);
 {
   try {
     simcall_comm_wait(comm->s_comm, timeout);
-    SIMIX_comm_unref(comm->s_comm);
+    comm->s_comm->unref();
 
     if (comm->task_received != nullptr) {
       /* I am the receiver */
 
     if (comm->task_received != nullptr) {
       /* I am the receiver */
@@ -672,7 +671,7 @@ int MSG_comm_waitany(xbt_dynar_t comms)
   if (comm->task_received != nullptr) {
     /* I am the receiver */
     (*comm->task_received)->simdata->setNotUsed();
   if (comm->task_received != nullptr) {
     /* I am the receiver */
     (*comm->task_received)->simdata->setNotUsed();
-    SIMIX_comm_unref(comm->s_comm);
+    comm->s_comm->unref();
   }
 
   return finished_index;
   }
 
   return finished_index;
@@ -800,7 +799,7 @@ msg_error_t MSG_task_send_with_timeout(msg_task_t task, const char *alias, doubl
       simcall_set_category(comm, task->category);
     t_simdata->comm = static_cast<simgrid::kernel::activity::CommImpl*>(comm);
     simcall_comm_wait(comm, timeout);
       simcall_set_category(comm, task->category);
     t_simdata->comm = static_cast<simgrid::kernel::activity::CommImpl*>(comm);
     simcall_comm_wait(comm, timeout);
-    SIMIX_comm_unref(comm);
+    comm->unref();
   }
   catch (xbt_ex& e) {
     switch (e.category) {
   }
   catch (xbt_ex& e) {
     switch (e.category) {
index 4ecb4e6..d8c635b 100644 (file)
@@ -24,7 +24,7 @@ Comm::~Comm()
     xbt_backtrace_display_current();
   }
   if (pimpl_)
     xbt_backtrace_display_current();
   }
   if (pimpl_)
-    SIMIX_comm_unref(pimpl_);
+    pimpl_->unref();
 }
 
 s4u::CommPtr Comm::send_init(s4u::MailboxPtr chan)
 }
 
 s4u::CommPtr Comm::send_init(s4u::MailboxPtr chan)
index 050fe62..ad1998e 100644 (file)
@@ -111,7 +111,7 @@ void SIMIX_process_cleanup(smx_actor_t process)
       if (comm->detached)
         XBT_DEBUG("Don't destroy it since it's a detached comm and I'm the sender");
       else
       if (comm->detached)
         XBT_DEBUG("Don't destroy it since it's a detached comm and I'm the sender");
       else
-        SIMIX_comm_unref(comm);
+        comm->unref();
     } else if (comm->dst_proc == process) {
       XBT_DEBUG("Found an unfinished recv comm %p, state %d, src = %p, dst = %p",
           comm, (int)comm->state, comm->src_proc, comm->dst_proc);
     } else if (comm->dst_proc == process) {
       XBT_DEBUG("Found an unfinished recv comm %p, state %d, src = %p, dst = %p",
           comm, (int)comm->state, comm->src_proc, comm->dst_proc);
@@ -443,7 +443,7 @@ void SIMIX_process_kill(smx_actor_t process, smx_actor_t issuer) {
       auto i = boost::range::find(process->waiting_synchro->simcalls, &process->simcall);
       if (i != process->waiting_synchro->simcalls.end())
         process->waiting_synchro->simcalls.remove(&process->simcall);
       auto i = boost::range::find(process->waiting_synchro->simcalls, &process->simcall);
       if (i != process->waiting_synchro->simcalls.end())
         process->waiting_synchro->simcalls.remove(&process->simcall);
-      SIMIX_comm_unref(comm);
+      comm->unref();
     } else if (sleep != nullptr) {
       SIMIX_process_sleep_destroy(process->waiting_synchro);
 
     } else if (sleep != nullptr) {
       SIMIX_process_sleep_destroy(process->waiting_synchro);
 
index 74cdf59..b9e5ced 100644 (file)
@@ -58,7 +58,7 @@ _find_matching_comm(boost::circular_buffer_space_optimized<smx_activity_t>* dequ
       XBT_DEBUG("Found a matching communication synchro %p", comm);
       if (remove_matching)
         deque->erase(it);
       XBT_DEBUG("Found a matching communication synchro %p", comm);
       if (remove_matching)
         deque->erase(it);
-      SIMIX_comm_ref(comm);
+      comm->ref();
 #if SIMGRID_HAVE_MC
       comm->mbox_cpy = comm->mbox;
 #endif
 #if SIMGRID_HAVE_MC
       comm->mbox_cpy = comm->mbox;
 #endif
@@ -115,7 +115,7 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx
       //this mailbox is for small messages, which have to be sent right now
       other_comm->state   = SIMIX_READY;
       other_comm->dst_proc=mbox->permanent_receiver.get();
       //this mailbox is for small messages, which have to be sent right now
       other_comm->state   = SIMIX_READY;
       other_comm->dst_proc=mbox->permanent_receiver.get();
-      other_comm          = static_cast<simgrid::kernel::activity::CommImpl*>(SIMIX_comm_ref(other_comm));
+      other_comm->ref();
       mbox->done_comm_queue.push_back(other_comm);
       XBT_DEBUG("pushing a message into the permanent receive list %p, comm %p", mbox, other_comm);
 
       mbox->done_comm_queue.push_back(other_comm);
       XBT_DEBUG("pushing a message into the permanent receive list %p, comm %p", mbox, other_comm);
 
@@ -124,8 +124,8 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx
     }
   } else {
     XBT_DEBUG("Receive already pushed");
     }
   } else {
     XBT_DEBUG("Receive already pushed");
-    SIMIX_comm_unref(this_comm);
-    SIMIX_comm_unref(this_comm);
+    this_comm->unref();
+    this_comm->unref();
 
     other_comm->state = SIMIX_READY;
     other_comm->type = SIMIX_COMM_READY;
 
     other_comm->state = SIMIX_READY;
     other_comm->type = SIMIX_COMM_READY;
@@ -193,7 +193,7 @@ smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void *
   //communication already done, get it inside the list of completed comms
   if (mbox->permanent_receiver != nullptr && not mbox->done_comm_queue.empty()) {
 
   //communication already done, get it inside the list of completed comms
   if (mbox->permanent_receiver != nullptr && not mbox->done_comm_queue.empty()) {
 
-    SIMIX_comm_unref(this_synchro);
+    this_synchro->unref();
     XBT_DEBUG("We have a comm that has probably already been received, trying to match it, to skip the communication");
     //find a match in the list of already received comms
     other_comm = _find_matching_comm(&mbox->done_comm_queue, SIMIX_COMM_SEND, match_fun, data, this_synchro,
     XBT_DEBUG("We have a comm that has probably already been received, trying to match it, to skip the communication");
     //find a match in the list of already received comms
     other_comm = _find_matching_comm(&mbox->done_comm_queue, SIMIX_COMM_SEND, match_fun, data, this_synchro,
@@ -209,10 +209,10 @@ smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void *
         other_comm->state = SIMIX_DONE;
         other_comm->type = SIMIX_COMM_DONE;
         other_comm->mbox = nullptr;
         other_comm->state = SIMIX_DONE;
         other_comm->type = SIMIX_COMM_DONE;
         other_comm->mbox = nullptr;
-        SIMIX_comm_unref(other_comm);
+        other_comm->unref();
       }
       }
-      SIMIX_comm_unref(other_comm);
-      SIMIX_comm_unref(this_synchro);
+      other_comm->unref();
+      this_synchro->unref();
     }
   } else {
     /* Prepare a comm describing us, so that it gets passed to the user-provided filter of other side */
     }
   } else {
     /* Prepare a comm describing us, so that it gets passed to the user-provided filter of other side */
@@ -235,8 +235,8 @@ smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void *
 
       other_comm->state = SIMIX_READY;
       other_comm->type = SIMIX_COMM_READY;
 
       other_comm->state = SIMIX_READY;
       other_comm->type = SIMIX_COMM_READY;
-      SIMIX_comm_unref(this_synchro);
-      SIMIX_comm_unref(this_synchro);
+      this_synchro->unref();
+      this_synchro->unref();
     }
     dst_proc->comms.push_back(other_comm);
   }
     }
     dst_proc->comms.push_back(other_comm);
   }
@@ -295,9 +295,9 @@ smx_activity_t SIMIX_comm_iprobe(smx_actor_t dst_proc, smx_mailbox_t mbox, int t
   }
 
   if(other_synchro)
   }
 
   if(other_synchro)
-    SIMIX_comm_unref(other_synchro);
+    other_synchro->unref();
 
 
-  SIMIX_comm_unref(this_comm);
+  this_comm->unref();
   return other_synchro;
 }
 
   return other_synchro;
 }
 
@@ -721,18 +721,3 @@ void SIMIX_comm_copy_data(smx_activity_t synchro)
   /* (this function might be called from both communication ends) */
   comm->copied = 1;
 }
   /* (this function might be called from both communication ends) */
   comm->copied = 1;
 }
-
-/** Increase the refcount for this comm */
-smx_activity_t SIMIX_comm_ref(smx_activity_t comm)
-{
-  if (comm != nullptr)
-    comm->ref();
-  return comm;
-}
-
-/** Decrease the refcount for this comm */
-void SIMIX_comm_unref(smx_activity_t comm)
-{
-  if (comm != nullptr)
-    comm->unref();
-}