NAME
OTK_JobQueue -
Job queue which understands TK, UNIX signals, time and I/O events.
SYNOPSIS
#include <OTK/dispatch/jobqueue.hh>
class OTK_JobQueue : public OTC_JobQueue
{
public:
OTK_JobQueue();
~OTK_JobQueue();
OTC_Job* next();
virtual OTC_Job* next(int theActions, int theTkActions=0);
inline int dispatch(int theActions=0);
};
CLASS TYPE
Concrete
DESCRIPTION
OTK_JobQueue is a derived version of OTC_JobQueue which
understands how to manage signals, alarms, timers and I/O events,
within the UNIX environment.
When the next() member function is invoked to return the
next job to execute, the class first checks for any signals
which may have occurred. If no signals have occurred, a check
is made for any alarms which may have expired. Checks are then
made for normal jobs, and finally a select() or poll() call is
made to check for timer and I/O events.
When a request is made for a specific type of job, the valid
flags which can OR'ed together are:
- OUXLIB_SIGNAL_JOBS
- OUXLIB_ALARM_JOBS
- OUXLIB_TIMEOUT_JOBS
- OUXLIB_IO_JOBS
- OUXLIB_IDLE_JOBS
If OUXLIB_DONT_WAIT is included in the set of flags, the
function will return without executing a job if the function would
have needed to block in order to get a job. The value 0 can be
used to select all event sources, or OUXLIB_DONT_WAIT by itself
if all event sources should be select but it shouldn't block.
QUEUEING
OTC_Job* next();
Returns the next job to be executed.
If there are alarms or timers which
have not expired, or file descriptors
being waited upon, this function will
block if necessary.
virtual OTC_Job* next(int theActions, int theTkActions=0);
Returns a job to be executed. The type of
job and whether the function blocks is
determined by theActions. If theActions
is 0, all event sources will be checked
and the function will block if necessary.
If non zero, theActions should be the
OR'ed combination of the flags defined
by the enum OUX_JobActions.
theTkActions is used internally only and
should always be left as 0.
DISPATCH
inline int dispatch(int theActions=0);
Dispatches a single job according to the
flags set in theActions. The default for
theActions is 0, which results in all
events sources being checked, and if
necessary cause the function to block. If
non zero, theActions should be the OR'ed
value of the flags defined by the
enumerated type OUX_JobActions. The
flags can be used to return a job for a
specific event source, or cause the
function not to block. Asking for a single
idle job to be executed will result in all
idle jobs having to be executed before
timer and events on file descriptors will
once again be checked. If a job is
executed, then 1 is returned. If there
were no jobs, or the function
would have blocked when it had been
directed not to, then 0 is returned.
SEE ALSO
OTC_JobQueue, OTC_Job, OUXEV_Signal, OTCEV_Alarm,
OTCEV_Timeout, OTCEV_IOEvent, OUX_Dispatcher,
OTK_JobQueue
LIBRARY
OTK
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1993 TELSTRA CORPORATION LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED