Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
New functions: s4u::Actor::property() and s4u::Actor::setProperty()
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 5 May 2017 20:40:50 +0000 (22:40 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 5 May 2017 20:40:50 +0000 (22:40 +0200)
include/simgrid/s4u/Actor.hpp
src/s4u/s4u_actor.cpp

index 24f7437..bef7072 100644 (file)
@@ -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
index de5b546..4841225 100644 (file)
@@ -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 {