Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
port a blocking simcall to the modernity
[simgrid.git] / src / s4u / s4u_Actor.cpp
index 438c476..5732d13 100644 (file)
@@ -28,6 +28,7 @@ xbt::signal<void(Actor const&)> s4u::Actor::on_sleep;
 xbt::signal<void(Actor const&)> s4u::Actor::on_wake_up;
 xbt::signal<void(Actor const&)> s4u::Actor::on_migration_start;
 xbt::signal<void(Actor const&)> s4u::Actor::on_migration_end;
+xbt::signal<void(Actor const&)> s4u::Actor::on_termination;
 xbt::signal<void(Actor const&)> s4u::Actor::on_destruction;
 
 // ***** Actor creation *****
@@ -76,17 +77,32 @@ void intrusive_ptr_release(Actor* actor)
 {
   intrusive_ptr_release(actor->pimpl_);
 }
+int Actor::get_refcount()
+{
+  return pimpl_->get_refcount();
+}
 
 // ***** Actor methods *****
 
 void Actor::join()
 {
-  simcall_process_join(this->pimpl_, -1);
+  join(-1);
 }
 
 void Actor::join(double timeout)
 {
-  simcall_process_join(this->pimpl_, timeout);
+  auto issuer = SIMIX_process_self();
+  auto target = pimpl_;
+  simix::simcall_blocking([issuer, target, timeout] {
+    if (target->finished_) {
+      // The joined process is already finished, just wake up the issuer right away
+      issuer->simcall_answer();
+    } else {
+      smx_activity_t sync = issuer->join(target, timeout);
+      sync->simcalls_.push_back(&issuer->simcall);
+      issuer->waiting_synchro = sync;
+    }
+  });
 }
 
 void Actor::set_auto_restart(bool autorestart)