summaryrefslogtreecommitdiff
path: root/lib/Task.cc
diff options
context:
space:
mode:
authorPixel <Pixel>2001-11-23 11:26:50 +0000
committerPixel <Pixel>2001-11-23 11:26:50 +0000
commit1311938cc52369b8631c29f83a9ecdf4a5f12f19 (patch)
tree4ec27df25d3df977631e62a82c11fd387a28b8c2 /lib/Task.cc
parent0497d21e5b7b483259642aad1f23392995863c17 (diff)
Last modifications...
Diffstat (limited to 'lib/Task.cc')
-rw-r--r--lib/Task.cc34
1 files changed, 27 insertions, 7 deletions
diff --git a/lib/Task.cc b/lib/Task.cc
index a56a2ff..b54402f 100644
--- a/lib/Task.cc
+++ b/lib/Task.cc
@@ -4,11 +4,11 @@
#include "Task.h"
#include "String.h"
-Task::Task() : state(TASK_ON_HOLD), suspended(false), cleanup(false), current(0) {
+Task::Task() : current(0), state(TASK_ON_HOLD), stopped(false), cleanup(false), suspended(false) {
TaskMan::AddTask(this);
}
+
Task::~Task() {
- TaskMan::RemoveTask(this);
}
int Task::Do() throw (GeneralException) {
@@ -23,7 +23,7 @@ int Task::Run() {
}
catch (TaskSwitch) {
cerr << "Catch a task switching.\n";
- throw;
+ return state;
}
catch (GeneralException e) {
cerr << "Task " << GetName() << " caused an unexpected exception: '" << e.GetMsg() << "', closing it.\n";
@@ -53,18 +53,38 @@ void Task::WaitFor(Handle * h, int flags) {
w4ha.push_back(w4ha_t(h, flags));
}
-void Task::WaitFor(Task * t, int flags) {
- w4ta.push_back(w4ta_t(t, flags));
+void Task::WaitFor(Task * t) {
+ t->wbta.push_back(wbta_t(this));
}
-void Task::WaitFor(pid_t p, int flags) {
- w4pr.push_back(w4pr_t(p, flags));
+void Task::WaitFor(pid_t p) {
+ w4pr.push_back(w4pr_t(p));
}
void Task::WaitFor(timeval t, int flags) {
w4to.push_back(w4to_t(t, flags));
}
+bool Task::WaitingFor(Handle * ha) {
+ vector<w4ha_t>::iterator p;
+
+ for (p = w4ha.begin(); p && (p != w4ha.end()); p++) {
+ if (p->ha == ha) return true;
+ }
+
+ return false;
+}
+
+bool Task::WaitingFor(pid_t pr) {
+ vector<w4pr_t>::iterator p;
+
+ for (p = w4pr.begin(); p && (p != w4pr.end()); p++) {
+ if (p->pr == pr) return true;
+ }
+
+ return false;
+}
+
void Task::SetBurst() {
state = TASK_BURST;
}