2 #include "simdag/simdag.h"
4 #include "xbt/sysdep.h"
7 /* Creates a link and registers it in SD.
9 SD_link_t __SD_link_create(void *surf_link, void *data) {
11 xbt_assert0(surf_link != NULL, "surf_link is NULL !");
14 SD_link_t link = xbt_new0(s_SD_link_t, 1);
15 link->surf_link = surf_link;
16 link->data = data; /* user data */
18 const char *name = SD_link_get_name(link);
19 xbt_dict_set(sd_global->links, name, link, __SD_link_destroy); /* add the link to the dictionary */
25 * \brief Returns the user data of a link
28 * \return the user data associated with this link (can be \c NULL)
29 * \see SD_link_set_data()
31 void* SD_link_get_data(SD_link_t link) {
33 xbt_assert0(link != NULL, "Invalid parameter");
38 * \brief Sets the user data of a link
40 * The new data can be \c NULL. The old data should have been freed first
41 * if it was not \c NULL.
44 * \param data the new data you want to associate with this link
45 * \see SD_link_get_data()
47 void SD_link_set_data(SD_link_t link, void *data) {
49 xbt_assert0(link != NULL, "Invalid parameter");
54 * \brief Returns the name of a link
57 * \return the name of this link (cannot be \c NULL)
59 const char* SD_link_get_name(SD_link_t link) {
61 xbt_assert0(link != NULL, "Invalid parameter");
62 return surf_workstation_resource->extension_public->get_link_name(link->surf_link);
66 * \brief Returns the current bandwidth of a link
69 * \return the current bandwidth of this link, in Flops
71 double SD_link_get_current_bandwidth(SD_link_t link) {
73 xbt_assert0(link != NULL, "Invalid parameter");
74 return surf_workstation_resource->extension_public->get_link_bandwidth(link->surf_link);
78 * \brief Returns the current latency of a link
81 * \return the current latency of this link, in seconds
83 double SD_link_get_current_latency(SD_link_t link) {
85 xbt_assert0(link != NULL, "Invalid parameter");
86 return surf_workstation_resource->extension_public->get_link_latency(link->surf_link);
91 void __SD_link_destroy(void *link) {
93 xbt_assert0(link != NULL, "Invalid parameter");
94 /* link->surf_link is freed by surf_exit and link->data is freed by the user */