From 7bfa729b876a8c3e0f32ca4cb9c39d595e66b610 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 5 May 2017 22:40:50 +0200 Subject: [PATCH] New functions: s4u::Actor::property() and s4u::Actor::setProperty() --- include/simgrid/s4u/Actor.hpp | 4 ++++ src/s4u/s4u_actor.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+) 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 { -- 2.20.1