Changeset db34424 in mainline
- Timestamp:
- 2019-08-07T09:37:45Z (6 years ago)
- Children:
- cf172c5
- Parents:
- 9532981
- git-author:
- Michal Koutný <xm.koutny+hos@…> (2015-11-03 00:15:00)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-07 09:37:45)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/sysman/edge.c
r9532981 rdb34424 41 41 } 42 42 43 static unit_edge_t *edge_extract_internal(unit_t *input, unit_t *output) 44 { 45 list_foreach(input->edges_out, edges_out, unit_edge_t, e) { 46 if (e->output == output) { 47 return e; 48 } 49 } 50 51 return NULL; 52 } 53 43 54 unit_edge_t *edge_create(void) 44 55 { … … 68 79 int edge_sprout_out(unit_t *input, const char *output_name) 69 80 { 81 int rc; 70 82 unit_edge_t *e = edge_create(); 71 int rc;72 83 73 84 if (e == NULL) { … … 76 87 } 77 88 89 //TODO check multi-edges 78 90 e->output_name = str_dup(output_name); 79 91 if (e->output_name == NULL) { … … 94 106 } 95 107 96 void edge_resolve_output(unit_edge_t *e, unit_t * unit)108 void edge_resolve_output(unit_edge_t *e, unit_t *output) 97 109 { 98 110 assert(e->output == NULL); 99 111 assert(e->output_name != NULL); 100 112 101 // TODO add to other side edges_in list 102 e->output = unit; 113 e->output = output; 114 list_append(&e->edges_in, output->edges_id); 115 103 116 free(e->output_name); 104 117 e->output_name = NULL; … … 109 122 * @return EOK on success 110 123 * @return ENOMEM 124 * @return EEXISTS 111 125 */ 112 126 int edge_connect(unit_t *input, unit_t *output) 113 127 { 128 if (edge_extract_internal(input, output)) { 129 return EEXISTS; 130 } 131 114 132 unit_edge_t *e = edge_create(); 115 133 if (e == NULL) { … … 117 135 } 118 136 119 // TODO check existence of the e120 // TODO locking121 // TODO check types and states of connected units122 137 list_append(&e->edges_in, &output->edges_in); 123 138 list_append(&e->edges_out, &input->edges_out); … … 128 143 } 129 144 130 /** Remove output from outputgraph145 /** Remove edge from dependency graph 131 146 * 132 * Given outputis removed from graph and unallocated.147 * Given edge is removed from graph and unallocated. 133 148 */ 134 149 void edge_remove(unit_edge_t **e_ptr) 135 150 { 136 // TODO here should be some checks, othewise replace this wrapper with 137 // direct destroy 151 /* 152 * So far it's just passing, however, edge_destroy is considered 153 * low-level and edge_remove could later e.g. support transactions. 154 */ 138 155 edge_destroy(e_ptr); 139 156 }
Note:
See TracChangeset
for help on using the changeset viewer.