Re: How to maintain responsiveness during long functions?



The ideal solution is to split up the working into small chunks and get an
idle function to take care of it.

The other solution is to call the following code during the working every
now and again:
  if (gtk_events_pending())
    gtk_main_iteration();

In general, I have found that the first solution runs faster and gives a
more responsive interface, but requires a bit more thinking to implement
correctly.  (It also has the advantage that it is easier to cancel the
thinking, if that is important).

James.

--
Email: james@daa.com.au
WWW:   http://www.daa.com.au/~james/


On Thu, 24 Jun 1999, Ian Peters wrote:

> Hello,
> 
> Recently, two people have sent me some very good reversi algorithms
> for inclusion into iagno.  Since many people have complained about the
> skill level of the computer players (very low), this is a good thing.
> However, obviously both algorithms need to spend a good bit of time
> thinking, and currently, this means that the game does not respond (ie
> menus, redraws, etc are not handled) until the computer makes its
> move.
> 
> What is the `proper' way to handle this?  Is there any simple way to
> tell it to process any pending events at critical junctions in the
> algorithm, or do I have to either restructure the algorithms to work
> through with the gtk event system, or make the application threaded?
> 
> Any assistance that anyone can provide would be much, much
> appreciated.
> 
> -- 
> Ian Peters  | GnuPG Key ID 5C23D20C    | "He that breaks a thing to find out
> itp@gnu.org | E584 2558 FAC3 BEAB EFAC |  what it is has left the path of
> itp@acm.org | FC74 CFED 7E24 5C23 D20C |  wisdom." -- J.R.R. Tolkien
> 
> 
> -- 
> To unsubscribe: mail gnome-devel-list-request@gnome.org with "unsubscribe"
> as the Subject.
> 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]