]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: Add more getters to threadpool parameters
authorErik Skultety <eskultet@redhat.com>
Thu, 25 Feb 2016 12:14:36 +0000 (13:14 +0100)
committerErik Skultety <eskultet@redhat.com>
Mon, 18 Apr 2016 15:07:18 +0000 (17:07 +0200)
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: Erik Skultety <eskultet@redhat.com>
src/libvirt_private.syms
src/util/virthreadpool.c
src/util/virthreadpool.h

index 61fc5004bbb7b96c89eaf1681872e5a04a1ea15b..6d90eca6758f620f04cd274113856277a0527a2e 100644 (file)
@@ -2365,6 +2365,9 @@ virThreadJobSetWorker;
 
 # util/virthreadpool.h
 virThreadPoolFree;
+virThreadPoolGetCurrentWorkers;
+virThreadPoolGetFreeWorkers;
+virThreadPoolGetJobQueueDepth;
 virThreadPoolGetMaxWorkers;
 virThreadPoolGetMinWorkers;
 virThreadPoolGetPriorityWorkers;
index 7ceb090a998b80fc5b76576e1ed8edf6c504563b..fec8620c10bb84059d243f9c2fed64438af3944d 100644 (file)
@@ -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
index 538b62fb1a61cea948559ddf10ea0448b921796f..bc0c90771be02f6fd81993ad0f0743ca0cea85d1 100644 (file)
@@ -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);