Subject: Re: POW: speed up bulk spell checking
From: David Mandelin (mandelin@cs.wisc.edu)
Date: Wed Aug 29 2001 - 10:47:37 CDT
Ben Mesman wrote:
>
> >
> > Yes. Once can set the priority but that leaves the problem of how to avoid
> > 100% CPU useage.
> >
> > Here is an idea. If the function called by ->fire() return false, the
> > function is removed from the gtk_idle queue.
> >
> > For a background spellchecking, after each block is spell-checked, the
> > function could return true if there was another block in the queue and
> > false if not.
> >
> > Spell-checking would be restarted via a timer::set() or timer::start() and
> > continue until all the blocks are spell checked.
> >
> > What do think?
>
> I think this is not a good idea. This is because this is very platform
> dependant. If there is a similar mechanism in Win32, it will probably
> not remove the function from the queue if it returns false).
For the record, AFAIK, win32 has no analogue to gtk_idle_add. But you
can use a fancier event loop:
while (1) {
PeekMessage(...); // extract msg from queue if avail, nonblocking
if (got msg) {
dispatch it
} else {
if (have idle function) {
cont = true
while (cont) {
cont = idle();
}
}
GetMessage(...); // extract msg from queue, blocking
}
}
It calls the idle function when idle. It doesn't use 100% cpu when the
idle function has no work to do. Can this work in gtk?
This archive was generated by hypermail 2b25 : Wed Aug 29 2001 - 10:47:41 CDT