mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-29 17:33:09 +00:00
virthreadpool: Cleanup
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
b05cca197f
commit
8278ca919e
@ -325,61 +325,43 @@ void virThreadPoolFree(virThreadPool *pool)
|
|||||||
size_t virThreadPoolGetMinWorkers(virThreadPool *pool)
|
size_t virThreadPoolGetMinWorkers(virThreadPool *pool)
|
||||||
{
|
{
|
||||||
VIR_LOCK_GUARD lock = virLockGuardLock(&pool->mutex);
|
VIR_LOCK_GUARD lock = virLockGuardLock(&pool->mutex);
|
||||||
size_t ret;
|
|
||||||
|
|
||||||
ret = pool->minWorkers;
|
return pool->minWorkers;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t virThreadPoolGetMaxWorkers(virThreadPool *pool)
|
size_t virThreadPoolGetMaxWorkers(virThreadPool *pool)
|
||||||
{
|
{
|
||||||
VIR_LOCK_GUARD lock = virLockGuardLock(&pool->mutex);
|
VIR_LOCK_GUARD lock = virLockGuardLock(&pool->mutex);
|
||||||
size_t ret;
|
|
||||||
|
|
||||||
ret = pool->maxWorkers;
|
return pool->maxWorkers;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t virThreadPoolGetPriorityWorkers(virThreadPool *pool)
|
size_t virThreadPoolGetPriorityWorkers(virThreadPool *pool)
|
||||||
{
|
{
|
||||||
VIR_LOCK_GUARD lock = virLockGuardLock(&pool->mutex);
|
VIR_LOCK_GUARD lock = virLockGuardLock(&pool->mutex);
|
||||||
size_t ret;
|
|
||||||
|
|
||||||
ret = pool->nPrioWorkers;
|
return pool->nPrioWorkers;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t virThreadPoolGetCurrentWorkers(virThreadPool *pool)
|
size_t virThreadPoolGetCurrentWorkers(virThreadPool *pool)
|
||||||
{
|
{
|
||||||
VIR_LOCK_GUARD lock = virLockGuardLock(&pool->mutex);
|
VIR_LOCK_GUARD lock = virLockGuardLock(&pool->mutex);
|
||||||
size_t ret;
|
|
||||||
|
|
||||||
ret = pool->nWorkers;
|
return pool->nWorkers;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t virThreadPoolGetFreeWorkers(virThreadPool *pool)
|
size_t virThreadPoolGetFreeWorkers(virThreadPool *pool)
|
||||||
{
|
{
|
||||||
VIR_LOCK_GUARD lock = virLockGuardLock(&pool->mutex);
|
VIR_LOCK_GUARD lock = virLockGuardLock(&pool->mutex);
|
||||||
size_t ret;
|
|
||||||
|
|
||||||
ret = pool->freeWorkers;
|
return pool->freeWorkers;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t virThreadPoolGetJobQueueDepth(virThreadPool *pool)
|
size_t virThreadPoolGetJobQueueDepth(virThreadPool *pool)
|
||||||
{
|
{
|
||||||
VIR_LOCK_GUARD lock = virLockGuardLock(&pool->mutex);
|
VIR_LOCK_GUARD lock = virLockGuardLock(&pool->mutex);
|
||||||
size_t ret;
|
|
||||||
|
|
||||||
ret = pool->jobQueueDepth;
|
return pool->jobQueueDepth;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -394,12 +376,12 @@ int virThreadPoolSendJob(virThreadPool *pool,
|
|||||||
virThreadPoolJob *job;
|
virThreadPoolJob *job;
|
||||||
|
|
||||||
if (pool->quit)
|
if (pool->quit)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
if (pool->freeWorkers - pool->jobQueueDepth <= 0 &&
|
if (pool->freeWorkers - pool->jobQueueDepth <= 0 &&
|
||||||
pool->nWorkers < pool->maxWorkers &&
|
pool->nWorkers < pool->maxWorkers &&
|
||||||
virThreadPoolExpand(pool, 1, false) < 0)
|
virThreadPoolExpand(pool, 1, false) < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
job = g_new0(virThreadPoolJob, 1);
|
job = g_new0(virThreadPoolJob, 1);
|
||||||
|
|
||||||
@ -424,9 +406,6 @@ int virThreadPoolSendJob(virThreadPool *pool,
|
|||||||
virCondSignal(&pool->prioCond);
|
virCondSignal(&pool->prioCond);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -444,7 +423,7 @@ virThreadPoolSetParameters(virThreadPool *pool,
|
|||||||
if (min > max) {
|
if (min > max) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
_("minWorkers cannot be larger than maxWorkers"));
|
_("minWorkers cannot be larger than maxWorkers"));
|
||||||
goto error;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((maxWorkers == 0 && pool->maxWorkers > 0) ||
|
if ((maxWorkers == 0 && pool->maxWorkers > 0) ||
|
||||||
@ -452,14 +431,13 @@ virThreadPoolSetParameters(virThreadPool *pool,
|
|||||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
_("maxWorkers must not be switched from zero to non-zero"
|
_("maxWorkers must not be switched from zero to non-zero"
|
||||||
" and vice versa"));
|
" and vice versa"));
|
||||||
goto error;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minWorkers >= 0) {
|
if (minWorkers >= 0) {
|
||||||
if ((size_t) minWorkers > pool->nWorkers &&
|
if ((size_t) minWorkers > pool->nWorkers &&
|
||||||
virThreadPoolExpand(pool, minWorkers - pool->nWorkers,
|
virThreadPoolExpand(pool, minWorkers - pool->nWorkers, false) < 0)
|
||||||
false) < 0)
|
return -1;
|
||||||
goto error;
|
|
||||||
pool->minWorkers = minWorkers;
|
pool->minWorkers = minWorkers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,15 +452,12 @@ virThreadPoolSetParameters(virThreadPool *pool,
|
|||||||
} else if ((size_t) prioWorkers > pool->nPrioWorkers &&
|
} else if ((size_t) prioWorkers > pool->nPrioWorkers &&
|
||||||
virThreadPoolExpand(pool, prioWorkers - pool->nPrioWorkers,
|
virThreadPoolExpand(pool, prioWorkers - pool->nPrioWorkers,
|
||||||
true) < 0) {
|
true) < 0) {
|
||||||
goto error;
|
return -1;
|
||||||
}
|
}
|
||||||
pool->maxPrioWorkers = prioWorkers;
|
pool->maxPrioWorkers = prioWorkers;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user