CTCLIdleProcess

Name

CTCLIdleProcess --  Allows the establishment of an executable object that can be scheduled to be invoked when the Tcl/Tk intperpreter has no events that require processing.

Synopsis


#include <TCLIdleProcess.h>

class CTCLIdleProcess : protected CTCLTimer
{
public:
  CTCLIdleProcess(CTCLInterpreterObject* pObject);
  CTCLIdleProcess(CTCLInterpreter* pInterp);
  virtual ~CTCLIdleProcess();

  void Set();
  void Clear();
  virtual void operator()() = 0;
};
    

DESCRIPTION

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().

METHODS


  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.


  void Set();
  void Clear();
            

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.

SEE ALSO

CTCLTimer(3), Tcl_CreateTimerHandler(3tcl), Tcl_DoWhenIdle(3tcl),

REFERENCES


Musser, Derge, Saini: STL Tutorial and Reference Guide
Addison-Wesley Professional Computing Series; 2001 ISBN 0-201-37923-6
See section 2.4 for a description and discussion of function objects.