summaryrefslogtreecommitdiff
path: root/lib/Task.cc
diff options
context:
space:
mode:
authorPixel <Pixel>2001-11-25 23:50:14 +0000
committerPixel <Pixel>2001-11-25 23:50:14 +0000
commit9707409e4d15eadac9b3c752c3c6877788943a58 (patch)
tree58a8ef3851967415fd21674648f02c42e8eab4cd /lib/Task.cc
parent8b6b771ca421f4f08f58debbf5459b020cf1bef7 (diff)
Wow, everything almost work!!! Amazing!!!
Diffstat (limited to 'lib/Task.cc')
-rw-r--r--lib/Task.cc21
1 files changed, 11 insertions, 10 deletions
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;
+}