Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Actor: make the refcount observable, and improve debug messages
[simgrid.git] / src / s4u / s4u_Actor.cpp
index fe048a5..4a45890 100644 (file)
@@ -76,6 +76,10 @@ void intrusive_ptr_release(Actor* actor)
 {
   intrusive_ptr_release(actor->pimpl_);
 }
+int Actor::get_refcount()
+{
+  return pimpl_->get_refcount();
+}
 
 // ***** Actor methods *****
 
@@ -289,11 +293,11 @@ void yield()
   simix::simcall([] { /* do nothing*/ });
 }
 
-XBT_PUBLIC void sleep_until(double timeout)
+XBT_PUBLIC void sleep_until(double wakeup_time)
 {
   double now = SIMIX_get_clock();
-  if (timeout > now)
-    sleep_for(timeout - now);
+  if (wakeup_time > now)
+    sleep_for(wakeup_time - now);
 }
 
 void execute(double flops)
@@ -442,11 +446,6 @@ void migrate(Host* new_host)
   SIMIX_process_self()->iface()->migrate(new_host);
 }
 
-void kill() /* deprecated */
-{
-  exit();
-}
-
 } // namespace this_actor
 } // namespace s4u
 } // namespace simgrid
@@ -673,3 +672,39 @@ void sg_actor_detach()
 {
   simgrid::kernel::actor::ActorImpl::detach();
 }
+
+aid_t sg_actor_self_get_pid()
+{
+  return simgrid::s4u::this_actor::get_pid();
+}
+
+aid_t sg_actor_self_get_ppid()
+{
+  return simgrid::s4u::this_actor::get_ppid();
+}
+
+const char* sg_actor_self_get_name()
+{
+  return simgrid::s4u::this_actor::get_cname();
+}
+
+sg_actor_t sg_actor_self()
+{
+  return simgrid::s4u::Actor::self();
+}
+
+void sg_actor_self_execute(double flops)
+{
+  simgrid::s4u::this_actor::execute(flops);
+}
+
+/** @brief Take an extra reference on that actor to prevent it to be garbage-collected */
+void sg_actor_ref(sg_actor_t actor)
+{
+  intrusive_ptr_add_ref(actor);
+}
+/** @brief Release a reference on that actor so that it can get be garbage-collected */
+void sg_actor_unref(sg_actor_t actor)
+{
+  intrusive_ptr_release(actor);
+}