5 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
8 units_new(runner_t runner, fstreams_t fstreams)
10 register fstream_t fstream;
12 units_t units = xbt_new0(s_units_t, 1);
14 if(!(units->items = vector_new(fstreams_get_size(fstreams), unit_free)))
21 vector_rewind(fstreams->items);
23 while((fstream = vector_get(fstreams->items)))
25 if((errno = vector_push_back(units->items, unit_new(runner, NULL, fstream))))
27 vector_free(&(units->items));
32 vector_move_next(fstreams->items);
40 units_is_empty(units_t units)
48 return vector_is_empty(units->items);
52 units_get_size(units_t units)
60 return vector_get_size(units->items);
65 units_run_all(units_t units, xbt_os_mutex_t mutex)
72 if(vector_is_empty(units->items))
75 /* move the cursor at the begining of the vector */
76 vector_rewind(units->items);
78 /* run all the units */
79 while((unit = vector_get(units->items)))
81 unit_run(unit, mutex);
82 vector_move_next(units->items);
91 units_join_all(units_t units)
98 if(vector_is_empty(units->items))
101 /* move the cursor at the begining of the vector */
102 vector_rewind(units->items);
104 /* run all the units */
105 while((unit = vector_get(units->items)))
108 xbt_os_thread_join(unit->thread, NULL);
110 vector_move_next(units->items);
117 units_interrupt_all(units_t units)
119 register unit_t unit;
124 if(vector_is_empty(units->items))
127 /* move the cursor at the begining of the vector */
128 vector_rewind(units->items);
130 /* run all the units */
131 while((unit = vector_get(units->items)))
133 if(!(unit->successeded) && !(unit->interrupted))
134 unit_interrupt(unit);
136 vector_move_next(units->items);
143 units_verbose(units_t units)
145 register unit_t unit;
150 if(vector_is_empty(units->items))
153 /* move the cursor at the begining of the vector */
154 vector_rewind(units->items);
156 /* run all the units */
157 while((unit = vector_get(units->items)))
160 vector_move_next(units->items);
168 units_reset_all(units_t units)
170 register unit_t unit;
175 if(vector_is_empty(units->items))
178 /* move the cursor at the begining of the vector */
179 vector_rewind(units->items);
181 /* run all the units */
182 while((unit = vector_get(units->items)))
185 vector_move_next(units->items);
192 units_free(void** unitsptr)
197 if((errno = vector_free(&((*((units_t*)unitsptr))->items))))