#include <TCLIdleProcess.h> class CTCLIdleProcess : protected CTCLTimer { public: CTCLIdleProcess(CTCLInterpreterObject* pObject); CTCLIdleProcess(CTCLInterpreter* pInterp); virtual ~CTCLIdleProcess(); void Set(); void Clear(); virtual void operator()() = 0; };
While Tcl provides a mechanism for scheduling the execution of
a function when the interpreter main loop is idle (no pending events),
this is not suitable for processes that may need to be rescheduled.
Therefore, CTCLIdleProcess
is actually based on a
timer dispatch where the delay interval is 0ms.
CTCLIdleProcess
provides an abstract base class for creating function like classes that
are 'called' to run interleaved with the interpreter.
A function like class is one that implements operator()
(see REFERENCES) below. You can create an idle processor by creating
a subclass of CTCLIdleProcess
overriding
operator()
, creating an instance of that new class,
and invoking the Set()
function to schedule the
execution of the operator()
. Note that
It is possible for the code in your operator()
to
reschedule itself by calling Set()
.
CTCLIdleProcess
(CTCLInterpreterObject*pObject
);CTCLIdleProcess
(CTCLInterpreter*pInterp
);
Creates a CTCLIdleProcess
and initializes the timer on which this
is based. pInterp
is the interpreter that will schedule
the object's operator()
. pObject
points to an interpreter object who's interpreter will schedule the
operator()
to run.
voidSet
(); voidClear
();
These function control the scheduling of the operator()
call. Set
schedules the function to be called pretty much
the next time the interpreter loop is intered, while Clear
cancels a pending schedule.
virtual void operator()
() = 0;
This pure virtual function is overridden by your idle processor to provide the behavior of the idle processor.