Re: The idle loop issue


Subject: Re: The idle loop issue
From: Martin Sevior (msevior@mccubbin.ph.unimelb.edu.au)
Date: Fri Sep 07 2001 - 08:25:51 CDT


On Thu, 6 Sep 2001, Dom Lachowicz wrote:

> Hi,
>
> This is mainly directed at Martin but I'd appreciate everyone's input on the
> topic.
>
> It's ok if we want to add an idle-loop functionality to abiword. However, an
> idle is most certainly not a timer, and should not be contained inside of a
> UT_Timer class, though it might share some similar code (interface) with
> Timers. This should be split into some abstract base-class or interface which
> these 2 classes should share. Here are my requirements:
>
> 1) Separate UT_Timer and UT_Idle classes
> 2) Shared base class/interface between UT_Timer and UT_Idle
> 3) This "just works", or else we can conditionally fallback to using timers.
>
> Class heirarchy:
>
> UT_Worker
> |
> -----
> | |
> UT_Timer UT_Idle
>
> These classes should share *only* a selective interface, and *NO*
> implementation. This will probably mean that we need to restructure our timers
> a bit, but that shouldn't be too bad.
>
> Then we can use this later in our code:
>
> #ifdef USING_IDLES
> UT_Worker * checker = new UT_Idle ();
> #else // USING_TIMERS
> UT_Worker * checker = new UT_Timer (SPELLCHECK_MILLISECONDS);
> #endif
>
> checker->setCallback (this::spellCheckWord);
> checker->setInstanceData (static_cast<void *>(this));
> checker->start ();
>

OK. I agree that this is a much better idea than to give a timer an idle
method. I think we should implement this and modify Ben's code
accordingly.

As other platforms discover how to implement idle functions we can add
them to the class, but in the mean time they fall back to timer behaviour.

> I'll try to cook up something shortly. Also note that using this UT_Idle class
> might be useful in the GTK+/GNOME port inside of the GR_UnixGraphics class to
> queue repaints during idle cycles.
>

I looked into this. We have to find a way to reliabally initiate and
remove idle calls otherwise we either miss repaints or consume 100% CPU
time. (Both yuck!)

Cheers

Martin



This archive was generated by hypermail 2b25 : Fri Sep 07 2001 - 08:25:58 CDT