[gnome-builder] thread-pool: add counters for tracking threadpool work



commit 396368526602223ffdec3ca61a60683af60ffe14
Author: Christian Hergert <christian hergert me>
Date:   Thu May 7 19:00:22 2015 -0700

    thread-pool: add counters for tracking threadpool work

 libide/ide-thread-pool.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-thread-pool.c b/libide/ide-thread-pool.c
index 07910c1..bd7523a 100644
--- a/libide/ide-thread-pool.c
+++ b/libide/ide-thread-pool.c
@@ -18,6 +18,8 @@
 
 #define G_LOG_DOMAIN "ide-thread-pool"
 
+#include "egg-counter.h"
+
 #include "ide-debug.h"
 #include "ide-thread-pool.h"
 
@@ -29,6 +31,9 @@ typedef struct
   GTaskThreadFunc  func;
 } WorkItem;
 
+EGG_DEFINE_COUNTER (TotalTasks, "ThreadPool", "Total Tasks", "Total number of tasks processed.")
+EGG_DEFINE_COUNTER (QueuedTasks, "ThreadPool", "Queued Tasks", "Current number of pending tasks.")
+
 static GThreadPool *gThreadPools [IDE_THREAD_POOL_LAST];
 
 static inline GThreadPool *
@@ -60,6 +65,8 @@ ide_thread_pool_push_task (IdeThreadPoolKind  kind,
   g_return_if_fail (G_IS_TASK (task));
   g_return_if_fail (func != NULL);
 
+  EGG_COUNTER_INC (TotalTasks);
+
   pool = ide_thread_pool_get_pool (kind);
 
   if (pool != NULL)
@@ -70,6 +77,8 @@ ide_thread_pool_push_task (IdeThreadPoolKind  kind,
       work_item->task = g_object_ref (task);
       work_item->func = func;
 
+      EGG_COUNTER_INC (QueuedTasks);
+
       g_thread_pool_push (pool, work_item, NULL);
     }
   else
@@ -91,6 +100,8 @@ ide_thread_pool_worker (gpointer data,
 
   g_assert (work_item != NULL);
 
+  EGG_COUNTER_DEC (QueuedTasks);
+
   source_object = g_task_get_source_object (work_item->task);
   task_data = g_task_get_task_data (work_item->task);
   cancellable = g_task_get_cancellable (work_item->task);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]