WvStreams
wvsubprocqueuestream.cc
1 /*
2  * Worldvisions Weaver Software:
3  * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4  *
5  * A more convenient way to use WvSubProcQueue. See wvsubprocqueuestream.h.
6  */
7 #include "wvsubprocqueuestream.h"
8 
9 
10 WvSubProcQueueStream::WvSubProcQueueStream(int _maxrunning)
11  : WvSubProcQueue(_maxrunning), log("Subproc Queue", WvLog::Debug5)
12 {
13  alarm(0);
14 }
15 
16 
17 WvSubProcQueueStream::~WvSubProcQueueStream()
18 {
19 }
20 
21 
23 {
24  int started = WvSubProcQueue::go();
25  int run = running(), remain = remaining();
26  if (started || run || remain)
27  log("Started %s processes (%s running, %s waiting)\n",
28  started, run, remain - run);
29  if (!remain)
30  alarm(1000); // nothing is even in the queue; come back later.
31  else if (started)
32  alarm(0); // we're busy; go fast if possible
33  else
34  alarm(100); // no processes were ready *this* time; wait longer
35 }
36 
37 
WvSubProcQueueStream::execute
virtual void execute()
The callback() function calls execute(), and then calls the user- specified callback if one is define...
Definition: wvsubprocqueuestream.cc:22
WvSubProcQueue::running
unsigned running() const
Return the number of currently running processes.
Definition: wvsubprocqueue.cc:134
WvLog
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
Definition: wvlog.h:56
WvSubProcQueue
An ordered queue of WvSubProc instances.
Definition: wvsubprocqueue.h:58
WvSubProcQueue::go
int go()
Clean up after any running processes in the queue, and start running additional processes if any are ...
Definition: wvsubprocqueue.cc:72
WvStream::alarm
void alarm(time_t msec_timeout)
set an alarm, ie.
Definition: wvstream.cc:1048
WvSubProcQueue::remaining
unsigned remaining() const
Return the number of unfinished (ie. running or waiting) processes.
Definition: wvsubprocqueue.cc:140