From ff9409b1737627857eb47f64f536a3f66b6a09a4 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Mon, 11 Apr 2016 13:01:07 +0200 Subject: Imported Upstream version 2.0.0 --- TasksMeter.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'TasksMeter.c') diff --git a/TasksMeter.c b/TasksMeter.c index 22a125e..f3764d6 100644 --- a/TasksMeter.c +++ b/TasksMeter.c @@ -7,7 +7,7 @@ in the source distribution for its full text. #include "TasksMeter.h" -#include "ProcessList.h" +#include "Platform.h" #include "CRT.h" /*{ @@ -15,42 +15,53 @@ in the source distribution for its full text. }*/ int TasksMeter_attributes[] = { - TASKS_RUNNING + CPU_KERNEL, PROCESS_THREAD, PROCESS, TASKS_RUNNING }; static void TasksMeter_setValues(Meter* this, char* buffer, int len) { ProcessList* pl = this->pl; - this->total = pl->totalTasks; - this->values[0] = pl->runningTasks; - snprintf(buffer, len, "%d/%d", (int) this->values[0], (int) this->total); + this->values[0] = pl->kernelThreads; + this->values[1] = pl->userlandThreads; + this->values[2] = pl->totalTasks - pl->kernelThreads - pl->userlandThreads; + this->values[3] = pl->runningTasks; + if (pl->totalTasks > this->total) { + this->total = pl->totalTasks; + } + if (this->pl->settings->hideKernelThreads) { + this->values[0] = 0; + } + snprintf(buffer, len, "%d/%d", (int) this->values[3], (int) this->total); } static void TasksMeter_display(Object* cast, RichString* out) { Meter* this = (Meter*)cast; - ProcessList* pl = this->pl; + Settings* settings = this->pl->settings; char buffer[20]; - sprintf(buffer, "%d", (int)(this->total - pl->userlandThreads - pl->kernelThreads)); + + int processes = (int) this->values[2]; + + sprintf(buffer, "%d", processes); RichString_write(out, CRT_colors[METER_VALUE], buffer); int threadValueColor = CRT_colors[METER_VALUE]; int threadCaptionColor = CRT_colors[METER_TEXT]; - if (pl->highlightThreads) { + if (settings->highlightThreads) { threadValueColor = CRT_colors[PROCESS_THREAD_BASENAME]; threadCaptionColor = CRT_colors[PROCESS_THREAD]; } - if (!pl->hideUserlandThreads) { + if (!settings->hideUserlandThreads) { RichString_append(out, CRT_colors[METER_TEXT], ", "); - sprintf(buffer, "%d", (int)pl->userlandThreads); + sprintf(buffer, "%d", (int)this->values[1]); RichString_append(out, threadValueColor, buffer); RichString_append(out, threadCaptionColor, " thr"); } - if (!pl->hideKernelThreads) { + if (!settings->hideKernelThreads) { RichString_append(out, CRT_colors[METER_TEXT], ", "); - sprintf(buffer, "%d", (int)pl->kernelThreads); + sprintf(buffer, "%d", (int)this->values[0]); RichString_append(out, threadValueColor, buffer); RichString_append(out, threadCaptionColor, " kthr"); } RichString_append(out, CRT_colors[METER_TEXT], "; "); - sprintf(buffer, "%d", (int)this->values[0]); + sprintf(buffer, "%d", (int)this->values[3]); RichString_append(out, CRT_colors[TASKS_RUNNING], buffer); RichString_append(out, CRT_colors[METER_TEXT], " running"); } @@ -64,6 +75,7 @@ MeterClass TasksMeter_class = { .setValues = TasksMeter_setValues, .defaultMode = TEXT_METERMODE, .total = 100.0, + .maxItems = 4, .attributes = TasksMeter_attributes, .name = "Tasks", .uiName = "Task counter", -- cgit v1.2.3