X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c630e592bf768a21557ad91fd626ea5943449152..08a29a4221dc5cec95b766cd9b25c95dcc361df9:/src/s4u/s4u_Actor.cpp?ds=sidebyside diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index f31600a392..6cd3ede118 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -41,23 +41,23 @@ ActorPtr Actor::self() } ActorPtr Actor::init(std::string name, s4u::Host* host) { - return SIMIX_process_self()->init(std::move(name), host)->iface(); + smx_actor_t self = SIMIX_process_self(); + simgrid::kernel::actor::ActorImpl* actor = + simgrid::simix::simcall([self, name, host] { return self->init(std::move(name), host).get(); }); + return actor->ciface(); } -ActorPtr Actor::start(std::function code) +ActorPtr Actor::start(const std::function& code) { - simgrid::simix::simcall([this, code] { return this->get_impl()->start(code); }); + simgrid::simix::simcall([this, &code] { pimpl_->start(code); }); return this; } -ActorPtr Actor::create(std::string name, s4u::Host* host, std::function code) +ActorPtr Actor::create(std::string name, s4u::Host* host, const std::function& code) { - smx_actor_t self = SIMIX_process_self(); - - simgrid::kernel::actor::ActorImpl* actor = - simgrid::simix::simcall([self, name, host, code] { return self->init(std::move(name), host)->start(code); }); + simgrid::kernel::actor::ActorImpl* actor = simcall_process_create(std::move(name), code, nullptr, host, nullptr); - return actor->ciface(); + return actor->iface(); } ActorPtr Actor::create(std::string name, s4u::Host* host, const std::string& function, std::vector args) @@ -106,7 +106,12 @@ void Actor::on_exit(int_f_pvoid_pvoid_t fun, simgrid::simix::simcall([this, fun, data] { SIMIX_process_on_exit(pimpl_, fun, data); }); } -void Actor::on_exit(std::function const fun) +void Actor::on_exit(const std::function& fun, void* data) /* deprecated */ +{ + on_exit([fun, data](bool exit) { fun(exit, data); }); +} + +void Actor::on_exit(const std::function& fun) { simgrid::simix::simcall( [this, fun] { SIMIX_process_on_exit(pimpl_, [fun](int a, void* /*data*/) { fun(a != 0); }, nullptr); }); @@ -431,12 +436,12 @@ void exit() simgrid::simix::simcall([actor] { actor->exit(); }); } -void on_exit(std::function const fun) +void on_exit(const std::function& fun) { SIMIX_process_self()->iface()->on_exit(fun); } -void on_exit(std::function const fun, void* data) /* deprecated */ +void on_exit(const std::function& fun, void* data) /* deprecated */ { SIMIX_process_self()->iface()->on_exit([fun, data](bool exit) { fun(exit, data); }); }