From: Martin Quinson Date: Fri, 5 May 2017 20:40:50 +0000 (+0200) Subject: New functions: s4u::Actor::property() and s4u::Actor::setProperty() X-Git-Tag: v3.16~274^2~58 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/7bfa729b876a8c3e0f32ca4cb9c39d595e66b610?ds=sidebyside New functions: s4u::Actor::property() and s4u::Actor::setProperty() --- diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index 24f7437d11..bef7072932 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -269,6 +269,10 @@ public: /** Returns the internal implementation of this actor */ simix::ActorImpl* getImpl(); + + /** Retrieve the property value (or nullptr if not set) */ + const char* property(const char* key); + void setProperty(const char* key, const char* value); }; /** @ingroup s4u_api diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index de5b546865..48412257b0 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -151,6 +151,18 @@ void Actor::killAll(int resetPid) simcall_process_killall(resetPid); } +/** Retrieve the property value (or nullptr if not set) */ +const char* Actor::property(const char* key) +{ + return (char*)xbt_dict_get_or_null(simcall_process_get_properties(pimpl_), key); +} +void Actor::setProperty(const char* key, const char* value) +{ + simgrid::simix::kernelImmediate([this, key, value] { + xbt_dict_set(simcall_process_get_properties(pimpl_), key, (char*)value, (void_f_pvoid_t) nullptr); + }); +} + // ***** this_actor ***** namespace this_actor {