aboutsummaryrefslogtreecommitdiffstats
path: root/TasksMeter.c
diff options
context:
space:
mode:
Diffstat (limited to 'TasksMeter.c')
-rw-r--r--TasksMeter.c52
1 files changed, 20 insertions, 32 deletions
diff --git a/TasksMeter.c b/TasksMeter.c
index a760ce0..29d3dd1 100644
--- a/TasksMeter.c
+++ b/TasksMeter.c
@@ -23,51 +23,39 @@ static const int TasksMeter_attributes[] = {
TASKS_RUNNING
};
-static void TasksMeter_updateValues(Meter* this, char* buffer, size_t len) {
+static void TasksMeter_updateValues(Meter* this) {
const ProcessList* pl = this->pl;
this->values[0] = pl->kernelThreads;
this->values[1] = pl->userlandThreads;
this->values[2] = pl->totalTasks - pl->kernelThreads - pl->userlandThreads;
- this->values[3] = MINIMUM(pl->runningTasks, pl->cpuCount);
- if (pl->totalTasks > this->total) {
- this->total = pl->totalTasks;
- }
- if (pl->settings->hideKernelThreads) {
- this->values[0] = 0;
- }
- xSnprintf(buffer, len, "%d/%d", (int) this->values[3], (int) this->total);
+ this->values[3] = MINIMUM(pl->runningTasks, pl->activeCPUs);
+ this->total = pl->totalTasks;
+
+ xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%u/%u", MINIMUM(pl->runningTasks, pl->activeCPUs), pl->totalTasks);
}
static void TasksMeter_display(const Object* cast, RichString* out) {
const Meter* this = (const Meter*)cast;
const Settings* settings = this->pl->settings;
char buffer[20];
+ int len;
+
+ len = xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[2]);
+ RichString_appendnAscii(out, CRT_colors[METER_VALUE], buffer, len);
+
+ RichString_appendAscii(out, settings->hideUserlandThreads ? CRT_colors[METER_SHADOW] : CRT_colors[METER_TEXT], ", ");
+ len = xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[1]);
+ RichString_appendnAscii(out, settings->hideUserlandThreads ? CRT_colors[METER_SHADOW] : CRT_colors[TASKS_RUNNING], buffer, len);
+ RichString_appendAscii(out, settings->hideUserlandThreads ? CRT_colors[METER_SHADOW] : CRT_colors[METER_TEXT], " thr");
- int processes = (int) this->values[2];
+ RichString_appendAscii(out, settings->hideKernelThreads ? CRT_colors[METER_SHADOW] : CRT_colors[METER_TEXT], ", ");
+ len = xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[0]);
+ RichString_appendnAscii(out, settings->hideKernelThreads ? CRT_colors[METER_SHADOW] : CRT_colors[TASKS_RUNNING], buffer, len);
+ RichString_appendAscii(out, settings->hideKernelThreads ? CRT_colors[METER_SHADOW] : CRT_colors[METER_TEXT], " kthr");
- xSnprintf(buffer, sizeof(buffer), "%d", processes);
- RichString_writeAscii(out, CRT_colors[METER_VALUE], buffer);
- int threadValueColor = CRT_colors[METER_VALUE];
- int threadCaptionColor = CRT_colors[METER_TEXT];
- if (settings->highlightThreads) {
- threadValueColor = CRT_colors[PROCESS_THREAD_BASENAME];
- threadCaptionColor = CRT_colors[PROCESS_THREAD];
- }
- if (!settings->hideUserlandThreads) {
- RichString_appendAscii(out, CRT_colors[METER_TEXT], ", ");
- xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[1]);
- RichString_appendAscii(out, threadValueColor, buffer);
- RichString_appendAscii(out, threadCaptionColor, " thr");
- }
- if (!settings->hideKernelThreads) {
- RichString_appendAscii(out, CRT_colors[METER_TEXT], ", ");
- xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[0]);
- RichString_appendAscii(out, threadValueColor, buffer);
- RichString_appendAscii(out, threadCaptionColor, " kthr");
- }
RichString_appendAscii(out, CRT_colors[METER_TEXT], "; ");
- xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[3]);
- RichString_appendAscii(out, CRT_colors[TASKS_RUNNING], buffer);
+ len = xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[3]);
+ RichString_appendnAscii(out, CRT_colors[TASKS_RUNNING], buffer, len);
RichString_appendAscii(out, CRT_colors[METER_TEXT], " running");
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy