#include "simgrid/Exception.hpp"
#include "simgrid/actor.h"
+#include "simgrid/modelchecker.h"
#include "simgrid/s4u/Actor.hpp"
#include "simgrid/s4u/Exec.hpp"
#include "simgrid/s4u/Host.hpp"
#include "simgrid/s4u/VirtualMachine.hpp"
+#include "src/include/mc/mc.h"
#include "src/kernel/activity/ExecImpl.hpp"
+#include "src/mc/mc_replay.hpp"
#include "src/simix/smx_private.hpp"
#include "src/surf/HostImpl.hpp"
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 *****
{
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)
bool Actor::is_suspended()
{
- return simix::simcall([this] { return pimpl_->is_suspended(); });
+ return pimpl_->is_suspended();
}
void Actor::set_kill_time(double kill_time)
void sleep_for(double duration)
{
- if (duration > 0) {
- kernel::actor::ActorImpl* actor = SIMIX_process_self();
- Actor::on_sleep(*actor->ciface());
-
- simcall_process_sleep(duration);
+ xbt_assert(std::isfinite(duration), "duration is not finite!");
- Actor::on_wake_up(*actor->ciface());
+ if (duration > 0) {
+ kernel::actor::ActorImpl* issuer = SIMIX_process_self();
+ Actor::on_sleep(*issuer->ciface());
+
+ simix::simcall_blocking([issuer, duration]() {
+ if (MC_is_active() || MC_record_replay_is_active()) {
+ MC_process_clock_add(issuer, duration);
+ issuer->simcall_answer();
+ return;
+ }
+ smx_activity_t sync = issuer->sleep(duration);
+ sync->simcalls_.push_back(&issuer->simcall);
+ issuer->waiting_synchro = sync;
+
+ });
+
+ Actor::on_wake_up(*issuer->ciface());
}
}
{
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);
+}