WvStreams
|
00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * A class for running a series or set of processes, one at a time. 00006 */ 00007 #ifndef __WVSUBPROCQUEUE_H 00008 #define __WVSUBPROCQUEUE_H 00009 00010 #include "wvsubproc.h" 00011 00058 class WvSubProcQueue 00059 { 00060 public: 00065 WvSubProcQueue(unsigned _maxrunning); 00066 00067 virtual ~WvSubProcQueue(); 00068 00078 void add(void *cookie, WvSubProc *proc); 00079 00084 void add(void *cookie, const char *cmd, const char * const *argv); 00085 00095 int go(); 00096 00103 void finish(); 00104 00106 unsigned running() const; 00107 00109 unsigned remaining() const; 00110 00112 bool isempty() const; 00113 00114 private: 00115 struct Ent 00116 { 00117 Ent(void *_cookie, WvSubProc *_proc) 00118 { 00119 cookie = _cookie; 00120 proc = _proc; 00121 redo = false; 00122 } 00123 00124 ~Ent() 00125 { 00126 if (proc) delete proc; 00127 } 00128 00129 void *cookie; 00130 WvSubProc *proc; 00131 bool redo; 00132 }; 00133 DeclareWvList(Ent); 00134 00135 unsigned maxrunning; 00136 EntList runq, waitq; 00137 00138 bool cookie_running(); 00139 }; 00140 00141 00142 #endif // __WVSUBPROCQUEUE_H 00143