Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add sg_actor_list() and sg_actor_count()
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 1 Apr 2020 09:28:55 +0000 (11:28 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 1 Apr 2020 09:28:55 +0000 (11:28 +0200)
deprecate stuff for consistency and undynarification

include/simgrid/actor.h
include/simgrid/engine.h
include/simgrid/msg.h
src/msg/msg_legacy.cpp
src/msg/msg_process.cpp
src/s4u/s4u_Actor.cpp
src/s4u/s4u_Engine.cpp

index b35f30d..e97a0bc 100644 (file)
@@ -20,6 +20,9 @@ SG_BEGIN_DECL
     You should not access directly to the fields of the pointed structure, but always use the provided API to interact
     with actors.
  */
+XBT_PUBLIC size_t sg_actor_count();
+XBT_PUBLIC sg_actor_t* sg_actor_list();
+
 XBT_PUBLIC sg_actor_t sg_actor_create(const char* name, sg_host_t host, xbt_main_func_t code, int argc,
                                       const char* const* argv);
 XBT_PUBLIC sg_actor_t sg_actor_init(const char* name, sg_host_t host);
index e1b5eb1..66e74f5 100644 (file)
@@ -42,7 +42,7 @@ XBT_PUBLIC void simgrid_register_default(void (*code)(int, char**));
 /** Retrieve the simulation time (in seconds) */
 XBT_PUBLIC double simgrid_get_clock();
 /** Retrieve the number of actors in the simulation */
-XBT_PUBLIC int simgrid_get_actor_count();
+XBT_ATTRIB_DEPRECATED_v330("Please use sg_actor_count()") XBT_PUBLIC int simgrid_get_actor_count();
 
 /** @brief Allow other libraries to react to the --help flag, too
  *
index 8204478..64cc2cb 100644 (file)
@@ -341,8 +341,8 @@ XBT_PUBLIC msg_process_t MSG_process_attach(const char* name, void* data, msg_ho
 XBT_PUBLIC void MSG_process_detach();
 
 XBT_PUBLIC void MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup);
-XBT_PUBLIC xbt_dynar_t MSG_processes_as_dynar();
-XBT_PUBLIC int MSG_process_get_number();
+XBT_ATTRIB_DEPRECATED_v330("Please use sg_actor_list()") XBT_PUBLIC xbt_dynar_t MSG_processes_as_dynar();
+XBT_ATTRIB_DEPRECATED_v330("Please use sg_actor_count()") XBT_PUBLIC int MSG_process_get_number();
 
 XBT_PUBLIC void* MSG_process_get_data(const_sg_actor_t process);
 XBT_PUBLIC msg_error_t MSG_process_set_data(msg_process_t process, void* data);
index 26693aa..3e25d76 100644 (file)
@@ -218,9 +218,9 @@ void MSG_process_unref(const_sg_actor_t process)
   sg_actor_unref(process);
 }
 /** @brief Return the current number MSG processes. */
-int MSG_process_get_number()
+int MSG_process_get_number() // XBT_ATTRIB_DEPRECATED_v330
 {
-  return simgrid_get_actor_count();
+  return sg_actor_count();
 }
 /* ************************** NetZones *************************** */
 sg_netzone_t MSG_zone_get_root()
index 7b1055e..4432b25 100644 (file)
@@ -93,7 +93,8 @@ XBT_PUBLIC void MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup)
 }
 
 /** @brief returns a list of all currently existing processes */
-xbt_dynar_t MSG_processes_as_dynar() {
+xbt_dynar_t MSG_processes_as_dynar() // XBT_ATTRIB_DEPRECATED_v330
+{
   xbt_dynar_t res = xbt_dynar_new(sizeof(smx_actor_t), nullptr);
   for (auto const& kv : simix_global->process_list) {
     smx_actor_t actor = kv.second;
index 5937ec7..d6d6ae7 100644 (file)
@@ -471,6 +471,23 @@ void migrate(Host* new_host) // deprecated
 } // namespace simgrid
 
 /* **************************** Public C interface *************************** */
+size_t sg_actor_count()
+{
+  return simgrid::s4u::Engine::get_instance()->get_actor_count();
+}
+
+sg_actor_t* sg_actor_list()
+{
+  simgrid::s4u::Engine* e = simgrid::s4u::Engine::get_instance();
+  size_t actor_count      = e->get_actor_count();
+  xbt_assert(actor_count > 0, "There is no actor!");
+  std::vector<simgrid::s4u::ActorPtr> actors = e->get_all_actors();
+
+  sg_actor_t* res = xbt_new(sg_actor_t, actors.size());
+  for (size_t i = 0; i < actor_count; i++)
+    res[i] = actors[i].get();
+  return res;
+}
 
 sg_actor_t sg_actor_init(const char* name, sg_host_t host)
 {
index 8922d12..c773d0e 100644 (file)
@@ -459,7 +459,8 @@ double simgrid_get_clock()
 {
   return simgrid::s4u::Engine::get_clock();
 }
-int simgrid_get_actor_count()
+
+int simgrid_get_actor_count() // XBT_ATTRIB_DEPRECATED_v330
 {
   return simgrid::s4u::Engine::get_instance()->get_actor_count();
 }