diff options
author | Pixel <Pixel> | 2001-11-23 12:48:19 +0000 |
---|---|---|
committer | Pixel <Pixel> | 2001-11-23 12:48:19 +0000 |
commit | 8b6b771ca421f4f08f58debbf5459b020cf1bef7 (patch) | |
tree | b6b07ab038e1cde0d9067f44e728c2c21dd79f1c | |
parent | 1311938cc52369b8631c29f83a9ecdf4a5f12f19 (diff) |
Working on taskman...
-rw-r--r-- | include/Task.h | 29 | ||||
-rw-r--r-- | include/TaskMan.h | 31 | ||||
-rw-r--r-- | lib/Task.cc | 26 | ||||
-rw-r--r-- | lib/TaskMan.cc | 20 |
4 files changed, 53 insertions, 53 deletions
diff --git a/include/Task.h b/include/Task.h index 39b414f..cdc51c0 100644 --- a/include/Task.h +++ b/include/Task.h @@ -22,12 +22,10 @@ class Task : public Base { int Run(); int GetState(); void Suspend() throw (GeneralException); - void WaitFor(Handle *, int = 0); void WaitFor(Task *); + void WaitFor(Handle *, int = 0); void WaitFor(pid_t); - void WaitFor(struct timeval, int = 0); - bool WaitingFor(Handle *); - bool WaitingFor(pid_t); + void WaitFor(timeval, int = 0); void SetBurst(); void SetCleanUp(); bool HasToClean(); @@ -40,40 +38,17 @@ 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 wbta_t { public: wbta_t(Task * ata) : ta(ata) { } Task * ta; }; - class w4pr_t { - public: - w4pr_t(pid_t apr) : pr(apr) { } - pid_t pr; - }; - - 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<w4ha_t> w4ha; vector<wbta_t> wbta; - vector<w4pr_t> w4pr; - vector<w4to_t> w4to; }; #else diff --git a/include/TaskMan.h b/include/TaskMan.h index e1c59d0..e649956 100644 --- a/include/TaskMan.h +++ b/include/TaskMan.h @@ -10,13 +10,42 @@ class TaskMan : public Base { static int AddTask(Task *); static void Init() throw (GeneralException); static void MainLoop() throw (GeneralException); + static void WaitFor(Handle *, Task *, int = 0); + static void WaitFor(pid_t, Task *); + static void WaitFor(timeval, Task *, int = 0); - private: + class w4ha_t { + public: + w4ha_t(Handle * aha, int aflags, Task * aT) : ha(aha), flags(aflags), T(aT) { } + Handle * ha; + int flags; + Task * T; + }; + + class w4pr_t { + public: + w4pr_t(pid_t apr, Task * aT) : pr(apr), T(aT) { } + pid_t pr; + Task * T; + }; + + class w4to_t { + public: + w4to_t(timeval ato, int aflags, Task * aT) : to(ato), flags(aflags), T(aT) { } + timeval to; + int flags; + Task * T; + }; typedef vector<Task *> TaskList_t; + + private: static TaskList_t TaskList; static TaskList_t Zombies; static int number; static bool inited; + static vector<w4ha_t> w4ha; + static vector<w4pr_t> w4pr; + static vector<w4to_t> w4to; }; #else diff --git a/lib/Task.cc b/lib/Task.cc index b54402f..4f36c7b 100644 --- a/lib/Task.cc +++ b/lib/Task.cc @@ -50,7 +50,7 @@ void Task::Suspend() throw (GeneralException) { } void Task::WaitFor(Handle * h, int flags) { - w4ha.push_back(w4ha_t(h, flags)); + TaskMan::WaitFor(h, this, flags); } void Task::WaitFor(Task * t) { @@ -58,31 +58,11 @@ void Task::WaitFor(Task * t) { } void Task::WaitFor(pid_t p) { - w4pr.push_back(w4pr_t(p)); + TaskMan::WaitFor(p, this); } 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; + TaskMan::WaitFor(t, this, flags); } void Task::SetBurst() { diff --git a/lib/TaskMan.cc b/lib/TaskMan.cc index 1af9234..bab9380 100644 --- a/lib/TaskMan.cc +++ b/lib/TaskMan.cc @@ -3,8 +3,12 @@ #include <vector.h> #include "TaskMan.h" -vector<Task *> TaskMan::TaskList; -vector<Task *> TaskMan::Zombies; +TaskMan::TaskList_t TaskMan::TaskList; +TaskMan::TaskList_t TaskMan::Zombies; +vector<TaskMan::w4ha_t> TaskMan::w4ha; +vector<TaskMan::w4pr_t> TaskMan::w4pr; +vector<TaskMan::w4to_t> TaskMan::w4to; + int TaskMan::number = 0; bool TaskMan::inited = false; @@ -40,6 +44,18 @@ int TaskMan::AddTask(Task * t) { return 0; } +void TaskMan::WaitFor(Handle * h, Task * t, int flags) { + w4ha.push_back(w4ha_t(h, flags, t)); +} + +void TaskMan::WaitFor(pid_t p, Task * t) { + w4pr.push_back(w4pr_t(p, t)); +} + +void TaskMan::WaitFor(timeval t, Task * T, int flags) { + w4to.push_back(w4to_t(t, flags, T)); +} + void TaskMan::MainLoop() throw (GeneralException) { TaskList_t::iterator p; Task * t; |