diff options
author | Nathan Scott <nathans@redhat.com> | 2023-08-31 11:56:43 +1000 |
---|---|---|
committer | Nathan Scott <nathans@redhat.com> | 2023-08-31 14:13:16 +1000 |
commit | b74673fe37fd379fc350789e696470556776d815 (patch) | |
tree | cbe4f036962c439f9c07a9c96302f5908f6410b0 /ProcessList.c | |
parent | 214166a049c2a6ac454dbb37b85b04c039a6a17a (diff) |
Rename ProcessList to ProcessTable throughout
Following up with some discusson from a few months back,
where it was proposed that ProcessTable is a better name.
This data structure is definitely not a list ... if it
was one-dimensional it'd be a set, but in practice it has
much more in common with a two-dimensional table.
The Process table is a familiar operating system concept
for many people too so it resonates a little in that way
as well.
Diffstat (limited to 'ProcessList.c')
-rw-r--r-- | ProcessList.c | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/ProcessList.c b/ProcessList.c deleted file mode 100644 index 516dcd7c..00000000 --- a/ProcessList.c +++ /dev/null @@ -1,94 +0,0 @@ -/* -htop - ProcessList.c -(C) 2004,2005 Hisham H. Muhammad -Released under the GNU GPLv2+, see the COPYING file -in the source distribution for its full text. -*/ - -#include "ProcessList.h" - -#include <assert.h> -#include <stdlib.h> -#include <string.h> - -#include "CRT.h" -#include "DynamicColumn.h" -#include "Hashtable.h" -#include "Macros.h" -#include "Platform.h" -#include "Vector.h" -#include "XUtils.h" - - -void ProcessList_init(ProcessList* this, const ObjectClass* klass, Machine* host, Hashtable* pidMatchList) { - Table_init(&this->super, klass, host); - - this->pidMatchList = pidMatchList; -} - -void ProcessList_done(ProcessList* this) { - Table_done(&this->super); -} - -Process* ProcessList_getProcess(ProcessList* this, pid_t pid, bool* preExisting, Process_New constructor) { - const Table* table = &this->super; - Process* proc = (Process*) Hashtable_get(table->table, pid); - *preExisting = proc != NULL; - if (proc) { - assert(Vector_indexOf(table->rows, proc, Row_idEqualCompare) != -1); - assert(Process_getPid(proc) == pid); - } else { - proc = constructor(table->host); - assert(proc->cmdline == NULL); - Process_setPid(proc, pid); - } - return proc; -} - -static void ProcessList_prepareEntries(Table* super) { - ProcessList* this = (ProcessList*) super; - this->totalTasks = 0; - this->userlandThreads = 0; - this->kernelThreads = 0; - this->runningTasks = 0; - - Table_prepareEntries(super); -} - -static void ProcessList_iterateEntries(Table* super) { - ProcessList* this = (ProcessList*) super; - // calling into platform-specific code - ProcessList_goThroughEntries(this); -} - -static void ProcessList_cleanupEntries(Table* super) { - Machine* host = super->host; - const Settings* settings = host->settings; - - // Finish process table update, culling any exit'd processes - for (int i = Vector_size(super->rows) - 1; i >= 0; i--) { - Process* p = (Process*) Vector_get(super->rows, i); - - // tidy up Process state after refreshing the ProcessList table - Process_makeCommandStr(p, settings); - - // keep track of the highest UID for column scaling - if (p->st_uid > host->maxUserId) - host->maxUserId = p->st_uid; - - Table_cleanupRow(super, (Row*) p, i); - } - - // compact the table in case of deletions - Table_compact(super); -} - -const TableClass ProcessList_class = { - .super = { - .extends = Class(Table), - .delete = ProcessList_delete, - }, - .prepare = ProcessList_prepareEntries, - .iterate = ProcessList_iterateEntries, - .cleanup = ProcessList_cleanupEntries, -}; |