Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add sg_actor_{get,set}_data()
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 15 Sep 2019 08:18:55 +0000 (10:18 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 15 Sep 2019 17:59:06 +0000 (19:59 +0200)
This fixes https://framagit.org/simgrid/simgrid/issues/31

ChangeLog
include/simgrid/actor.h
src/s4u/s4u_Actor.cpp

index 921805e..f1e5a2a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,9 @@ S4U:
    - on_time_advance: each time the clock advances
    - on_simulation_end: after simulation, before cleanups
    - on_deadlock: as the name implies.
+ - C bindings:
+   - sg_{host,actor}_{set,get}_data() now all exist.
+     Use them to attach user data to the object.
 
 MSG:
  - convert a new set of functions to the S4U C interface and move the old MSG
@@ -42,6 +45,7 @@ Bugs:
  - FG#28: add sg_actor_self (and other wrappers on this_actor methods)
  - FG#29 and FG#33: provide a new C API to mutexes and condition variables 
  - FG#30: convert MSG_process_{un}ref to sg_actor_{un}ref
+ - FG#31: per-actor data
  - FG#34: SG_BARRIER_SERIAL_THREAD?
  - FG#35: model-checker does not like buster-produced binaries
 
index e13893e..ba67224 100644 (file)
@@ -49,6 +49,8 @@ XBT_PUBLIC const char* sg_actor_self_get_name();
 XBT_PUBLIC void sg_actor_self_execute(double flops);
 XBT_PUBLIC void sg_actor_ref(sg_actor_t actor);
 XBT_PUBLIC void sg_actor_unref(sg_actor_t actor);
+XBT_PUBLIC void* sg_actor_get_data(sg_actor_t actor);
+XBT_PUBLIC void sg_actor_set_data(sg_actor_t actor, void* userdata);
 
 SG_END_DECL()
 
index 5f75e2a..64ce673 100644 (file)
@@ -740,3 +740,14 @@ void sg_actor_unref(sg_actor_t actor)
 {
   intrusive_ptr_release(actor);
 }
+
+/** @brief Return the user data of a #sg_actor_t */
+void* sg_actor_get_data(sg_actor_t actor)
+{
+  return actor->get_data();
+}
+/** @brief Set the user data of a #sg_actor_t */
+void sg_actor_set_data(sg_actor_t actor, void* userdata)
+{
+  actor->set_data(userdata);
+}