double process_kill_time);
/*********************************** Host *************************************/
-XBT_PUBLIC(xbt_dict_t) SIMIX_host_get_dict(void);
XBT_PUBLIC(smx_host_t) SIMIX_host_get_by_name(const char *name);
XBT_PUBLIC(smx_host_t) SIMIX_host_self(void);
XBT_PUBLIC(const char*) SIMIX_host_self_get_name(void);
*/
void MSG_create_environment(const char *file)
{
- xbt_dict_cursor_t c;
- smx_host_t h;
+ xbt_lib_cursor_t cursor;
+ void **data;
char *name;
SIMIX_create_environment(file);
/* Initialize MSG hosts */
- xbt_dict_foreach(SIMIX_host_get_dict(), c, name, h) {
- __MSG_host_create(h, NULL);
+ xbt_lib_foreach(host_lib, cursor, name, data) {
+ if(data[SIMIX_HOST_LEVEL])
+ __MSG_host_create((smx_host_t)data[SIMIX_HOST_LEVEL], NULL);
}
return;
}
msg_global = xbt_new0(s_MSG_Global_t, 1);
- msg_global->host = xbt_fifo_new();
msg_global->max_channel = 0;
msg_global->PID = 1;
msg_global->sent_msg = 0;
*/
MSG_error_t MSG_clean(void)
{
- xbt_fifo_item_t i = NULL;
- m_host_t h = NULL;
#ifdef HAVE_TRACING
TRACE_surf_release();
MSG_process_killall(0);
- xbt_fifo_foreach(msg_global->host, i, h, m_host_t) {
- __MSG_host_destroy(h);
- }
- xbt_fifo_free(msg_global->host);
-
free(msg_global);
msg_global = NULL;
}
SIMIX_req_host_set_data(workstation, host);
-
- /* Update global variables */
- xbt_fifo_unshift(msg_global->host, host);
+ xbt_lib_set(host_lib,name,MSG_HOST_LEVEL,host);
return host;
}
/*
* Real function to destroy a host.
* MSG_host_destroy is just a front_end that also removes it from
- * msg_global->host
*/
void __MSG_host_destroy(m_host_t host)
{
/* Clean host structure */
free(host->name);
free(host);
-
-
}
/** \ingroup m_host_management
*/
int MSG_get_host_number(void)
{
- return (xbt_fifo_size(msg_global->host));
+ return host_lib->count;
}
/** \ingroup m_host_management
*/
m_host_t *MSG_get_host_table(void)
{
- return ((m_host_t *) xbt_fifo_to_array(msg_global->host));
+ void **array;
+ int i = 0;
+ xbt_lib_cursor_t cursor;
+ char *key;
+ void **data;
+
+ if (host_lib->count == 0)
+ return NULL;
+ else
+ array = xbt_new0(void *, host_lib->count);
+
+ xbt_lib_foreach(host_lib, cursor, key, data) {
+ if(get_network_element_type(key) == SURF_NETWORK_ELEMENT_HOST)
+ array[i++] = data[MSG_HOST_LEVEL];
+ }
+
+ return (m_host_t *)array;
}
/** \ingroup m_host_management
/********************************** Simix Global ******************************/
typedef struct s_smx_global {
smx_context_factory_t context_factory;
- xbt_dict_t host;
xbt_dynar_t process_to_run;
xbt_swag_t process_list;
xbt_swag_t process_to_destroy;
simix_global = xbt_new0(s_smx_global_t, 1);
- simix_global->host = xbt_dict_new();
simix_global->process_to_run = xbt_dynar_new(sizeof(void *), NULL);
simix_global->process_list =
xbt_swag_new(xbt_swag_offset(proc, process_hookup));
simix_global->process_list = NULL;
simix_global->process_to_destroy = NULL;
xbt_dict_free(&(simix_global->registered_functions));
- xbt_dict_free(&(simix_global->host));
/* Let's free maestro now */
SIMIX_context_free(simix_global->maestro_process->context);
xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
/* Update global variables */
- xbt_dict_set(simix_global->host, smx_host->name, smx_host,
- &SIMIX_host_destroy);
+ xbt_lib_set(host_lib,smx_host->name,SIMIX_HOST_LEVEL,smx_host);
return smx_host;
}
return;
}
-/**
- * \brief Returns a dict of all hosts.
- *
- * \return List of all hosts (as a #xbt_dict_t)
- */
-xbt_dict_t SIMIX_host_get_dict(void)
-{
- return simix_global->host;
-}
-
smx_host_t SIMIX_host_get_by_name(const char *name)
{
xbt_assert0(((simix_global != NULL)
- && (simix_global->host != NULL)),
+ && (host_lib != NULL)),
"Environment not set yet");
- return xbt_dict_get_or_null(simix_global->host, name);
+ return xbt_lib_get_or_null(host_lib, name, SIMIX_HOST_LEVEL);
}
smx_host_t SIMIX_host_self(void)