A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
don't use old fashioned simcall when you don't have to
[simgrid.git]
/
src
/
s4u
/
s4u_Actor.cpp
diff --git
a/src/s4u/s4u_Actor.cpp
b/src/s4u/s4u_Actor.cpp
index
f31600a
..
fa4677e
100644
(file)
--- a/
src/s4u/s4u_Actor.cpp
+++ b/
src/s4u/s4u_Actor.cpp
@@
-39,31
+39,33
@@
ActorPtr Actor::self()
return self_context->get_actor()->iface();
}
return self_context->get_actor()->iface();
}
-ActorPtr Actor::init(
std::string
name, s4u::Host* host)
+ActorPtr Actor::init(
const std::string&
name, s4u::Host* host)
{
{
- return SIMIX_process_self()->init(std::move(name), host)->iface();
+ smx_actor_t self = SIMIX_process_self();
+ kernel::actor::ActorImpl* actor = simix::simcall([self, &name, host] { return self->init(name, host).get(); });
+ return actor->ciface();
}
}
-ActorPtr Actor::start(
std::function<void()>
code)
+ActorPtr Actor::start(
const std::function<void()>&
code)
{
{
- simgrid::simix::simcall([this,
code] { return this->get_impl()
->start(code); });
+ simgrid::simix::simcall([this,
&code] { pimpl_
->start(code); });
return this;
}
return this;
}
-ActorPtr Actor::create(
std::string name, s4u::Host* host, std::function<void()>
code)
+ActorPtr Actor::create(
const std::string& name, s4u::Host* host, const std::function<void()>&
code)
{
smx_actor_t self = SIMIX_process_self();
{
smx_actor_t self = SIMIX_process_self();
+ kernel::actor::ActorImpl* actor =
+ simix::simcall([self, &name, host, &code] { return self->init(name, host)->start(code); });
- simgrid::kernel::actor::ActorImpl* actor =
- simgrid::simix::simcall([self, name, host, code] { return self->init(std::move(name), host)->start(code); });
-
- return actor->ciface();
+ return actor->iface();
}
}
-ActorPtr Actor::create(std::string name, s4u::Host* host, const std::string& function, std::vector<std::string> args)
+ActorPtr Actor::create(const std::string& name, s4u::Host* host, const std::string& function,
+ std::vector<std::string> args)
{
simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
{
simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
- return create(
std::move(name)
, host, factory(std::move(args)));
+ return create(
name
, host, factory(std::move(args)));
}
void intrusive_ptr_add_ref(Actor* actor)
}
void intrusive_ptr_add_ref(Actor* actor)
@@
-106,7
+108,12
@@
void Actor::on_exit(int_f_pvoid_pvoid_t fun,
simgrid::simix::simcall([this, fun, data] { SIMIX_process_on_exit(pimpl_, fun, data); });
}
simgrid::simix::simcall([this, fun, data] { SIMIX_process_on_exit(pimpl_, fun, data); });
}
-void Actor::on_exit(std::function<void(bool /*failed*/)> const fun)
+void Actor::on_exit(const std::function<void(int, void*)>& fun, void* data) /* deprecated */
+{
+ on_exit([fun, data](bool exit) { fun(exit, data); });
+}
+
+void Actor::on_exit(const std::function<void(bool /*failed*/)>& fun)
{
simgrid::simix::simcall(
[this, fun] { SIMIX_process_on_exit(pimpl_, [fun](int a, void* /*data*/) { fun(a != 0); }, nullptr); });
{
simgrid::simix::simcall(
[this, fun] { SIMIX_process_on_exit(pimpl_, [fun](int a, void* /*data*/) { fun(a != 0); }, nullptr); });
@@
-248,12
+255,12
@@
std::unordered_map<std::string, std::string>* Actor::get_properties()
/** Retrieve the property value (or nullptr if not set) */
const char* Actor::get_property(const std::string& key)
{
/** Retrieve the property value (or nullptr if not set) */
const char* Actor::get_property(const std::string& key)
{
- return simgrid::simix::simcall([this, key] { return pimpl_->get_property(key); });
+ return simgrid::simix::simcall([this,
&
key] { return pimpl_->get_property(key); });
}
}
-void Actor::set_property(const std::string& key,
std::string
value)
+void Actor::set_property(const std::string& key,
const std::string&
value)
{
{
- simgrid::simix::simcall([this,
key, value] { pimpl_->set_property(key, std::move(value)
); });
+ simgrid::simix::simcall([this,
&key, &value] { pimpl_->set_property(key, value
); });
}
Actor* Actor::restart()
}
Actor* Actor::restart()
@@
-431,12
+438,12
@@
void exit()
simgrid::simix::simcall([actor] { actor->exit(); });
}
simgrid::simix::simcall([actor] { actor->exit(); });
}
-void on_exit(
std::function<void(bool)> const
fun)
+void on_exit(
const std::function<void(bool)>&
fun)
{
SIMIX_process_self()->iface()->on_exit(fun);
}
{
SIMIX_process_self()->iface()->on_exit(fun);
}
-void on_exit(
std::function<void(int, void*)> const
fun, void* data) /* deprecated */
+void on_exit(
const std::function<void(int, void*)>&
fun, void* data) /* deprecated */
{
SIMIX_process_self()->iface()->on_exit([fun, data](bool exit) { fun(exit, data); });
}
{
SIMIX_process_self()->iface()->on_exit([fun, data](bool exit) { fun(exit, data); });
}