summaryrefslogtreecommitdiff
path: root/lib/Task.cc
diff options
context:
space:
mode:
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;
}