7 #include "wvsubprocqueue.h" 14 maxrunning = _maxrunning;
18 WvSubProcQueue::~WvSubProcQueue()
26 assert(!proc->running);
30 EntList::Iter i(waitq);
31 for (i.rewind(); i.next(); )
33 if (i->cookie == cookie)
49 waitq.append(
new Ent(cookie, proc),
true);
54 const char *cmd,
const char *
const *argv)
57 p->preparev(cmd, argv);
62 bool WvSubProcQueue::cookie_running()
64 EntList::Iter i(runq);
65 for (i.rewind(); i.next(); )
81 EntList::Iter i(runq);
82 for (i.rewind(); i.next(); )
86 e->proc->wait(0,
true);
87 if (!e->proc->running)
95 waitq.append(e,
true);
103 while (!waitq.isempty() && runq.count() < maxrunning)
105 EntList::Iter i(waitq);
106 for (i.rewind(); i.next(); )
112 if (i->cookie && !runq.isempty())
114 if (cookie_running())
121 runq.append(e,
true);
122 e->proc->start_again();
129 assert(runq.count() <= maxrunning);
142 return runq.count() + waitq.count();
148 return runq.isempty() && waitq.isempty();
int go()
Clean up after any running processes in the queue, and start running additional processes if any are ...
void add(void *cookie, WvSubProc *proc)
Enqueue a process.
bool isempty() const
True if there are no unfinished (ie. running or waiting) processes.
unsigned running() const
Return the number of currently running processes.
unsigned remaining() const
Return the number of unfinished (ie. running or waiting) processes.
WvSubProcQueue(unsigned _maxrunning)
Create a WvSubProcQueue.
void finish()
Wait synchronously for all processes in the entire queue to finish.