summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/Task.h46
-rw-r--r--lib/CopyJob.cc4
-rw-r--r--lib/HttpServ.cc2
-rw-r--r--lib/ReadJob.cc4
-rw-r--r--lib/Task.cc16
5 files changed, 51 insertions, 21 deletions
diff --git a/include/Task.h b/include/Task.h
index b727cbe..b45bfea 100644
--- a/include/Task.h
+++ b/include/Task.h
@@ -12,6 +12,8 @@
#define TASK_DONE 1
#define TASK_BURST 2
+#define W4_STICKY 1
+
class Task : public Base {
public:
Task();
@@ -20,10 +22,10 @@ class Task : public Base {
int Run();
int GetState();
void Suspend() throw (GeneralException);
- void WaitFor(Handle *);
- void WaitFor(Task *);
- void WaitFor(pid_t);
- void WaitFor(struct timeval);
+ void WaitFor(Handle *, int = 0);
+ void WaitFor(Task *, int = 0);
+ void WaitFor(pid_t, int = 0);
+ void WaitFor(struct timeval, int = 0);
void SetBurst();
void SetCleanUp();
bool HasToClean();
@@ -36,14 +38,42 @@ class Task : public Base {
int current;
private:
+ class w4ha_t {
+ public:
+ w4ha_t(Handle * aha, int aflags) : ha(aha), flags(aflags) { }
+ Handle * ha;
+ int flags;
+ };
+
+ class w4ta_t {
+ public:
+ w4ta_t(Task * ata, int aflags) : ta(ata), flags(aflags) { }
+ Task * ta;
+ int flags;
+ };
+
+ class w4pr_t {
+ public:
+ w4pr_t(pid_t apr, int aflags) : pr(apr), flags(aflags) { }
+ pid_t pr;
+ int flags;
+ };
+
+ class w4to_t {
+ public:
+ w4to_t(timeval ato, int aflags) : to(ato), flags(aflags) { }
+ timeval to;
+ int flags;
+ };
+
int state;
bool stopped;
bool cleanup;
bool suspended;
- vector<Handle *> w4ha;
- vector<Task *> w4ta;
- vector<pid_t> w4pr;
- vector<timeval> w4to;
+ vector<w4ha_t> w4ha;
+ vector<w4ta_t> w4ta;
+ vector<w4pr_t> w4pr;
+ vector<w4to_t> w4to;
};
#else
diff --git a/lib/CopyJob.cc b/lib/CopyJob.cc
index 9dc9978..55fe59d 100644
--- a/lib/CopyJob.cc
+++ b/lib/CopyJob.cc
@@ -2,8 +2,8 @@
#include "General.h"
CopyJob::CopyJob(Handle * as, Handle * ad, ssize_t asiz, bool ads) : s(as), d(ad), siz(asiz), ds(ads), cursiz(0), r(0) {
- WaitFor(s);
- WaitFor(d);
+ WaitFor(s, W4_STICKY);
+ WaitFor(d, W4_STICKY);
}
CopyJob::~CopyJob() { }
diff --git a/lib/HttpServ.cc b/lib/HttpServ.cc
index fe48f54..cda572d 100644
--- a/lib/HttpServ.cc
+++ b/lib/HttpServ.cc
@@ -371,7 +371,7 @@ HttpServ::HttpServ(Action * ap, int port, const String & nname) throw (GeneralEx
}
Listener.SetNonBlock();
- WaitFor(&Listener);
+ WaitFor(&Listener, W4_STICKY);
cerr << "Mini HTTP-Server '" << name << "' ready and listening for port " << port << endl;
}
diff --git a/lib/ReadJob.cc b/lib/ReadJob.cc
index 9f037d9..f2749bb 100644
--- a/lib/ReadJob.cc
+++ b/lib/ReadJob.cc
@@ -2,8 +2,8 @@
#include "HttpServ.h"
ReadJob::ReadJob(Handle * as, Handle * ad) : s(as), d(ad) {
- WaitFor(s);
- WaitFor(d);
+ WaitFor(s, W4_STICKY);
+ WaitFor(d, W4_STICKY);
}
ReadJob::~ReadJob() { }
diff --git a/lib/Task.cc b/lib/Task.cc
index 4978bde..a56a2ff 100644
--- a/lib/Task.cc
+++ b/lib/Task.cc
@@ -49,20 +49,20 @@ void Task::Suspend() throw (GeneralException) {
throw TaskSwitch();
}
-void Task::WaitFor(Handle * h) {
- w4ha.push_back(h);
+void Task::WaitFor(Handle * h, int flags) {
+ w4ha.push_back(w4ha_t(h, flags));
}
-void Task::WaitFor(Task * t) {
- w4ta.push_back(t);
+void Task::WaitFor(Task * t, int flags) {
+ w4ta.push_back(w4ta_t(t, flags));
}
-void Task::WaitFor(pid_t p) {
- w4pr.push_back(p);
+void Task::WaitFor(pid_t p, int flags) {
+ w4pr.push_back(w4pr_t(p, flags));
}
-void Task::WaitFor(timeval t) {
- w4to.push_back(t);
+void Task::WaitFor(timeval t, int flags) {
+ w4to.push_back(w4to_t(t, flags));
}
void Task::SetBurst() {