#endif
#include "viralloc.h"
+#include "virthreadjob.h"
/* Nothing special required for pthreads */
struct virThreadArgs {
virThreadFunc func;
+ const char *funcName;
+ bool worker;
void *opaque;
};
/* Free args early, rather than tying it up during the entire thread. */
VIR_FREE(args);
+
+ if (local.worker)
+ virThreadJobSetWorker(local.funcName);
+ else
+ virThreadJobSet(local.funcName);
+
local.func(local.opaque);
+
+ if (!local.worker)
+ virThreadJobClear(0);
+
return NULL;
}
-int virThreadCreate(virThreadPtr thread,
- bool joinable,
- virThreadFunc func,
- void *opaque)
+int virThreadCreateFull(virThreadPtr thread,
+ bool joinable,
+ virThreadFunc func,
+ const char *funcName,
+ bool worker,
+ void *opaque)
{
struct virThreadArgs *args;
pthread_attr_t attr;
}
args->func = func;
+ args->funcName = funcName;
+ args->worker = worker;
args->opaque = opaque;
if (!joinable)
typedef void (*virThreadFunc)(void *opaque);
-int virThreadCreate(virThreadPtr thread,
- bool joinable,
- virThreadFunc func,
- void *opaque) ATTRIBUTE_RETURN_CHECK;
+# define virThreadCreate(thread, joinable, func, opaque) \
+ virThreadCreateFull(thread, joinable, func, #func, false, opaque)
+
+int virThreadCreateFull(virThreadPtr thread,
+ bool joinable,
+ virThreadFunc func,
+ const char *funcName,
+ bool worker,
+ void *opaque) ATTRIBUTE_RETURN_CHECK;
void virThreadSelf(virThreadPtr thread);
bool virThreadIsSelf(virThreadPtr thread);
void virThreadJoin(virThreadPtr thread);