@@ -30,10 +30,11 @@ static int minPrio = 0, maxPrio = 0, normalPrio = 0; struct thread_ctx { void (*function)(id object); id object; + const char *name; }; /* * This is done here to make sure this is done as early as possible in the main * thread. @@ -70,10 +71,13 @@ static void * functionWrapper(void *data) { struct thread_ctx *ctx = data; + if (ctx->name != NULL) + of_thread_set_name(ctx->name); + pthread_cleanup_push(free, data); ctx->function(ctx->object); pthread_cleanup_pop(1); @@ -99,12 +103,12 @@ return true; } bool -of_thread_new(of_thread_t *thread, void (*function)(id), id object, - const of_thread_attr_t *attr) +of_thread_new(of_thread_t *thread, const char *name, void (*function)(id), + id object, const of_thread_attr_t *attr) { bool ret; pthread_attr_t pattr; if (pthread_attr_init(&pattr) != 0) @@ -150,10 +154,11 @@ return false; } ctx->function = function; ctx->object = object; + ctx->name = name; ret = (pthread_create(thread, &pattr, functionWrapper, ctx) == 0); } @finally { pthread_attr_destroy(&pattr);