- /* If we are shutting down, the last worker is going to signal the
- * parmap so it can finish destroying the data structure */
- if(parmap->flags[worker_id] == PARMAP_DESTROY){
+ /* The end of the worker data segment must be bounded by the end of the data vector */
+ data_end = MIN(data_start + data_size, xbt_dynar_length(parmap->data));
+
+ DEBUG4("Worker %u: data_start=%u data_end=%u (data_size=%u)",
+ worker_id, data_start, data_end, data_size);
+
+ /* While the worker don't pass the end of it data segment apply the function */
+ while(data_start < data_end){
+ parmap->fun(*(void **)xbt_dynar_get_ptr(parmap->data, data_start));
+ data_start++;
+ }
+
+ xbt_barrier_wait(parmap->workers_done);
+
+ /* We are destroying the parmap */
+ }else{
+ xbt_barrier_wait(parmap->workers_done);