From ae4d1cfcbbe4c6130bd6370a03f546993a37f567 Mon Sep 17 00:00:00 2001 From: Pixel Date: Mon, 12 Nov 2001 22:20:50 +0000 Subject: Cleaning includes, progressing taskman... --- lib/TaskMan.cc | 53 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 6 deletions(-) (limited to 'lib/TaskMan.cc') diff --git a/lib/TaskMan.cc b/lib/TaskMan.cc index f8ba303..9abffb1 100644 --- a/lib/TaskMan.cc +++ b/lib/TaskMan.cc @@ -1,18 +1,59 @@ -#include +#include +#include "TaskMan.h" -bool TaskMan::Inited = false; +bool TaskMan::inited = false; + +static got_sigchild = 0; + +void taskman_sigchild(int sig) { + got_sigchild = 1; + signal(SIGCHILD, taskman_sigchild); +} TaskMan::TaskMan() throw (GeneralException) { - if (Inited) { - throw GeneralException("Another Task Manager is already running, aborting."); + throw GeneralException("You can't instanciate a Task Manager."); +} + +void TaskMan::Init() throw (GeneralException) { + if (inited) { + throw GeneralException("Task Manager already initialised."); } - Inited = true; + signal(SIGCHILD, taskman_sigchild); + + inited = true; + number = 0; } int TaskMan::AddTask(Task * t) { + TaskList.push_back(t); + number++; + + return 0; +} + +int TaskMan::RemoveTask(Task * t) { + int i; + for (i = 0; i < number; i++) { + if (TaskList[i] == t) { + TaskList.erase(i); + number--; + return 0; + } + } + return -1; } -void TaskMan::MainLoop() { +void TaskMan::MainLoop() throw (GeneralException) { + while (1) { + if (number == 0) { + throw GeneralException("TaskMan: No more task to manage."); + } + +#ifdef HAVE_POLL + +#else +#endif + } } -- cgit v1.2.3