XBT:
* New function: xbt_dynar_dopar(dynar,fun) to map a function over the
dynar with one separate thread per value of the dynar.
+ * Change the prototype of xbt_thread_create(), sorry.
+ Added a boolean parameter indicating whether we want to join this
+ thread (used in SG only for now)
Bug fixes:
* GTNetS wrappers should now be usable again (and betterly tested too)
/* spawn threads */
for (i = 0; i < philosopher_amount; i++) {
char *name = bprintf("thread %d", i);
- philosophers[i] = xbt_thread_create(name, philo_thread, &id[i]);
+ philosophers[i] = xbt_thread_create(name, philo_thread, &id[i],0/*not joinable*/);
free(name);
}
XBT_PUBLIC(xbt_thread_t) xbt_thread_create(const char *name,
void_f_pvoid_t start_routine,
- void *param);
+ void *param,int joinable);
XBT_PUBLIC(void) xbt_thread_exit();
XBT_PUBLIC(xbt_thread_t) xbt_thread_self(void);
XBT_PUBLIC(const char *) xbt_thread_name(xbt_thread_t t);
gras_msgtype_declare("_wakeup_listener", gras_datadesc_by_name("char"));
/* actually start the thread */
- arg->listener = xbt_thread_create("listener", listener_function, arg);
+ arg->listener = xbt_thread_create("listener", listener_function, arg,0/*not joinable*/);
gras_os_sleep(0); /* TODO: useless? give the listener a chance to initialize even if the main is empty and we cancel it right afterward */
return arg;
}
xbt_test_add0("==== Have a pusher and a popper on the dynar");
d = xbt_dynar_new_sync(sizeof(int), NULL);
- pusher = xbt_thread_create("pusher", pusher_f, d);
- poper = xbt_thread_create("poper", poper_f, d);
+ pusher = xbt_thread_create("pusher", pusher_f, d,0/*not joinable*/);
+ poper = xbt_thread_create("poper", poper_f, d,0/*not joinable*/);
xbt_thread_join(pusher);
xbt_thread_join(poper);
xbt_dynar_free(&d);
xbt_thread_t xbt_thread_create(const char *name, void_f_pvoid_t code,
- void *param)
+ void *param, int joinable)
{
xbt_thread_t res = xbt_new0(s_xbt_thread_t, 1);
w->function = function;
w->rank=cursor;
xbt_dynar_push(workers,&w);
- w->worker = xbt_thread_create("dopar worker",worker_wrapper,w);
+ w->worker = xbt_thread_create("dopar worker",worker_wrapper,w,1/*joinable*/);
}
/* wait them all */
xbt_dynar_free(&workers);
/* spawn threads */
for (i = 0; i < crasher_amount; i++) {
char *name = bprintf("thread %d", i);
- crashers[i] = xbt_thread_create(name, &crasher_thread, &id[i]);
+ crashers[i] = xbt_thread_create(name, &crasher_thread, &id[i],0/*not joinable*/);
free(name);
}