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);
/** 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
*
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);
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()
}
/** @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;
} // 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)
{
{
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();
}