From 9707409e4d15eadac9b3c752c3c6877788943a58 Mon Sep 17 00:00:00 2001 From: Pixel Date: Sun, 25 Nov 2001 23:50:14 +0000 Subject: Wow, everything almost work!!! Amazing!!! --- lib/Task.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'lib/Task.cc') diff --git a/lib/Task.cc b/lib/Task.cc index 4f36c7b..9ed1589 100644 --- a/lib/Task.cc +++ b/lib/Task.cc @@ -4,11 +4,12 @@ #include "Task.h" #include "String.h" -Task::Task() : current(0), state(TASK_ON_HOLD), stopped(false), cleanup(false), suspended(false) { +Task::Task() : current(0), state(TASK_ON_HOLD), stopped(false), cleanup(false), suspended(false), wbta(0) { TaskMan::AddTask(this); } Task::~Task() { + TaskMan::RemoveFromWatches(this); } int Task::Do() throw (GeneralException) { @@ -16,22 +17,16 @@ int Task::Do() throw (GeneralException) { } int Task::Run() { - cerr << "Running task '" << GetName() << "'...\n"; try { - cerr << "Launching method Do()...\n"; state = Do(); } catch (TaskSwitch) { - cerr << "Catch a task switching.\n"; return state; } catch (GeneralException e) { - cerr << "Task " << GetName() << " caused an unexpected exception: '" << e.GetMsg() << "', closing it.\n"; return TASK_DONE; } - cerr << "Task exitted normally.\n"; - return state; } @@ -43,8 +38,10 @@ String Task::GetName() { return "Unknow Task"; } -void Task::Suspend() throw (GeneralException) { - cerr << "Suspending task " << GetName() << "...\n"; +void Task::Suspend(int newstate) throw (GeneralException) { + if (newstate != -1) { + state = newstate; + } suspended = true; throw TaskSwitch(); } @@ -54,7 +51,7 @@ void Task::WaitFor(Handle * h, int flags) { } void Task::WaitFor(Task * t) { - t->wbta.push_back(wbta_t(this)); + t->wbta = this; } void Task::WaitFor(pid_t p) { @@ -88,3 +85,7 @@ void Task::Restart() { bool Task::IsStopped() { return stopped; } + +Task * Task::WaitedBy() { + return wbta; +} -- cgit v1.2.3