提交 c516e7d3 编写于 作者: E Erik Skultety

util: Add more getters to threadpool parameters

In order for the client to see all thread counts and limits, current total
and free worker count getters need to be introduced. Client might also be
interested in the job queue length, so provide a getter for that too. As with
the other getters, preparing for the admin interface, mutual exclusion is used
within all getters.
Signed-off-by: NErik Skultety <eskultet@redhat.com>
上级 e981607e
......@@ -2365,6 +2365,9 @@ virThreadJobSetWorker;
# util/virthreadpool.h
virThreadPoolFree;
virThreadPoolGetCurrentWorkers;
virThreadPoolGetFreeWorkers;
virThreadPoolGetJobQueueDepth;
virThreadPoolGetMaxWorkers;
virThreadPoolGetMinWorkers;
virThreadPoolGetPriorityWorkers;
......
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册