diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 61fc5004bb..6d90eca675 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2365,6 +2365,9 @@ virThreadJobSetWorker; # util/virthreadpool.h virThreadPoolFree; +virThreadPoolGetCurrentWorkers; +virThreadPoolGetFreeWorkers; +virThreadPoolGetJobQueueDepth; virThreadPoolGetMaxWorkers; virThreadPoolGetMinWorkers; virThreadPoolGetPriorityWorkers; diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c index 7ceb090a99..fec8620c10 100644 --- a/src/util/virthreadpool.c +++ b/src/util/virthreadpool.c @@ -317,6 +317,39 @@ size_t virThreadPoolGetPriorityWorkers(virThreadPoolPtr pool) return ret; } +size_t virThreadPoolGetCurrentWorkers(virThreadPoolPtr pool) +{ + size_t ret; + + virMutexLock(&pool->mutex); + ret = pool->nWorkers; + virMutexUnlock(&pool->mutex); + + return ret; +} + +size_t virThreadPoolGetFreeWorkers(virThreadPoolPtr pool) +{ + size_t ret; + + virMutexLock(&pool->mutex); + ret = pool->freeWorkers; + virMutexUnlock(&pool->mutex); + + return ret; +} + +size_t virThreadPoolGetJobQueueDepth(virThreadPoolPtr pool) +{ + size_t ret; + + virMutexLock(&pool->mutex); + ret = pool->jobQueueDepth; + virMutexUnlock(&pool->mutex); + + return ret; +} + /* * @priority - job priority * Return: 0 on success, -1 otherwise diff --git a/src/util/virthreadpool.h b/src/util/virthreadpool.h index 538b62fb1a..bc0c90771b 100644 --- a/src/util/virthreadpool.h +++ b/src/util/virthreadpool.h @@ -46,6 +46,9 @@ virThreadPoolPtr virThreadPoolNewFull(size_t minWorkers, size_t virThreadPoolGetMinWorkers(virThreadPoolPtr pool); size_t virThreadPoolGetMaxWorkers(virThreadPoolPtr pool); size_t virThreadPoolGetPriorityWorkers(virThreadPoolPtr pool); +size_t virThreadPoolGetCurrentWorkers(virThreadPoolPtr pool); +size_t virThreadPoolGetFreeWorkers(virThreadPoolPtr pool); +size_t virThreadPoolGetJobQueueDepth(virThreadPoolPtr pool); void virThreadPoolFree(virThreadPoolPtr pool);