worker = virThreadPoolNewFull(1, 1, 0,
virNWFilterDHCPDecodeWorker,
"dhcp-decode",
+ NULL,
req);
}
* running domains since there might occur some QEMU monitor
* events that will be dispatched to the worker pool */
qemu_driver->workerPool = virThreadPoolNewFull(0, 1, 0, qemuProcessEventHandler,
- "qemu-event", qemu_driver);
+ "qemu-event",
+ NULL,
+ qemu_driver);
if (!qemu_driver->workerPool)
goto error;
priority_workers,
virNetServerHandleJob,
"rpc-worker",
+ NULL,
srv)))
goto error;
virThreadPoolJobList jobList;
size_t jobQueueDepth;
+ virIdentity *identity;
+
virMutex mutex;
virCond cond;
virCond quit_cond;
virMutexLock(&pool->mutex);
+ if (pool->identity)
+ virIdentitySetCurrent(pool->identity);
+
while (1) {
/* In order to support async worker termination, we need ensure that
* both busy and free workers know if they need to terminated. Thus,
size_t prioWorkers,
virThreadPoolJobFunc func,
const char *name,
+ virIdentity *identity,
void *opaque)
{
virThreadPool *pool;
pool->jobName = name;
pool->jobOpaque = opaque;
+ if (identity)
+ pool->identity = g_object_ref(identity);
+
if (virMutexInit(&pool->mutex) < 0)
goto error;
if (virCondInit(&pool->cond) < 0)
virMutexLock(&pool->mutex);
virThreadPoolDrainLocked(pool);
+ if (pool->identity)
+ g_object_unref(pool->identity);
+
g_free(pool->workers);
virMutexUnlock(&pool->mutex);
virMutexDestroy(&pool->mutex);
#pragma once
#include "internal.h"
+#include "viridentity.h"
typedef struct _virThreadPool virThreadPool;
typedef void (*virThreadPoolJobFunc)(void *jobdata, void *opaque);
virThreadPool *virThreadPoolNewFull(size_t minWorkers,
- size_t maxWorkers,
- size_t prioWorkers,
- virThreadPoolJobFunc func,
- const char *name,
- void *opaque) ATTRIBUTE_NONNULL(4);
+ size_t maxWorkers,
+ size_t prioWorkers,
+ virThreadPoolJobFunc func,
+ const char *name,
+ virIdentity *identity,
+ void *opaque) ATTRIBUTE_NONNULL(4);
size_t virThreadPoolGetMinWorkers(virThreadPool *pool);
size_t virThreadPoolGetMaxWorkers(virThreadPool *pool);