diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Exceptions.h | 4 | ||||
-rw-r--r-- | include/Task.h | 28 | ||||
-rw-r--r-- | include/TaskMan.h | 18 |
3 files changed, 31 insertions, 19 deletions
diff --git a/include/Exceptions.h b/include/Exceptions.h index ebe8462..042059c 100644 --- a/include/Exceptions.h +++ b/include/Exceptions.h @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: Exceptions.h,v 1.42 2005-06-20 22:43:35 pixel Exp $ */ +/* $Id: Exceptions.h,v 1.43 2006-10-28 16:42:19 pixel Exp $ */ #ifndef __EXCEPTIONS_H__ #define __EXCEPTIONS_H__ @@ -68,6 +68,7 @@ class Base { } static int pipe(int * p, int flag = 0); static pid_t fork(); + static pid_t wait(int *); //! This wrapper will call the xexit function. static void exit(int); static void printm(int level, const ugly_string &, ...); @@ -106,6 +107,7 @@ void * xrealloc(void *, size_t); int xdup(int) throw (GeneralException); int xpipe(int *, int = 0) throw (GeneralException); pid_t xfork() throw (GeneralException); +pid_t xwait(int *) throw (GeneralException); //! This will simply throw the Exit exception. void xexit(int) throw (GeneralException); void xexception(const String &) throw (GeneralException); diff --git a/include/Task.h b/include/Task.h index 5ac4a26..8831830 100644 --- a/include/Task.h +++ b/include/Task.h @@ -9,16 +9,27 @@ #include <Exceptions.h> #include <Handle.h> -#define TASK_ON_HOLD 0 -#define TASK_DONE 1 -#define TASK_BURST 2 - -#define W4_STICKY 1 -#define W4_READING 2 -#define W4_WRITING 4 +#undef E_HANDLE class Task : public Base { public: + enum { + EVT_BURST = 0, + EVT_HANDLE, + EVT_PROCESS, + EVT_TIMEOUT, + EVT_TASK, + }; + enum { + TASK_ON_HOLD = 0, + TASK_DONE, + TASK_BURST, + }; + enum { + W4_STICKY = 1, + W4_READING = 2, + W4_WRITING = 4, + }; Task(); virtual ~Task(); virtual String GetName(); @@ -29,13 +40,14 @@ class Task : public Base { void WaitFor(Task *); void WaitFor(Handle *, int = 0); void WaitFor(pid_t); - void WaitFor(timeval, int = 0); + void WaitFor(const timeval &, int = 0); Task * WaitedBy(); void SetBurst(); void Stop(); void Restart(); bool IsStopped(); void RemoveFromWatches(); + Handle * BurstHandle; protected: virtual int Do() throw (GeneralException); diff --git a/include/TaskMan.h b/include/TaskMan.h index 5d7d034..7ceba4a 100644 --- a/include/TaskMan.h +++ b/include/TaskMan.h @@ -9,22 +9,17 @@ typedef int sigset_t; #include <Task.h> #include <vector> -#define E_BURST 0 -#define E_HANDLE 1 -#define E_PROCESS 2 -#define E_TIMEOUT 3 -#define E_TASK 4 - class TaskMan : public Base { public: static void AddTask(Task *); static std::vector<Task *>::iterator FindTask(Task *) throw (GeneralException); static void RemoveFromWatches(Task *); + static void RemoveTimeout(Task *); static void Init() throw (GeneralException); static void MainLoop() throw (GeneralException); static void WaitFor(Handle *, Task *, int = 0); static void WaitFor(pid_t, Task *, int = 0); - static void WaitFor(timeval, Task *, int = 0); + static void WaitFor(const timeval &, Task *, int = 0); static int GotChild(pid_t, int); static void Stop(); static int Event(); @@ -35,10 +30,10 @@ class TaskMan : public Base { class w4ha_t { public: - w4ha_t(Handle * aha, int aflags, Task * aT) : ha(aha), flags(aflags), dirthy(true), T(aT) { } + w4ha_t(Handle * aha, int aflags, Task * aT) : ha(aha), flags(aflags), dirty(true), T(aT) { } Handle * ha; int flags; - bool dirthy; + bool dirty; Task * T; }; @@ -52,7 +47,7 @@ class TaskMan : public Base { class w4to_t { public: - w4to_t(timeval ato, int aflags, Task * aT) : to(ato), flags(aflags), T(aT) { } + w4to_t(const timeval & ato, int aflags, Task * aT) : to(ato), flags(aflags), T(aT) { } timeval to; int flags; Task * T; @@ -73,6 +68,9 @@ class TaskMan : public Base { static Handle * ehandle; static int eprocess, estatus; static sigset_t sigchildset; + static int got_sigchild; + static bool CheckDead(Task *); + static void SigChild(); }; #endif |