Re: CPU consumption with GtkThread
Adrien <[email protected]> Tue, 14 Dec 2010 12:18:00 +0100
| Newsgroups | gmane.comp.lang.ocaml.lib.gtk |
|---|---|
| Message-ID | <[email protected]> |
Hi, I actually made it adaptive later on[1]. The drawback was that animations could take more time to update. The adaptative version worked quite well but reducing the delay wasn't instantaneous. It was pretty dumb and experimental, I could probably put more thought in it if needed. One of my test was using the acid3 test[2]. Basically, each step of the animation required one iteration of the loop. So depending on your uses it might or might not be a good idea. Then, at the OCaml Hacking Day, Jérémie Dimino told me to try Lwt's support[3]. Since you'll only be using lwt threads, you won't have to use GtkThread. IIRC it's only a matter of putting the following at the top of your code instead: let () = Lwt_glib.init () (and of course, link against lwt-glib) Haven't had issues with it and you don't have to use lwt everywhere, only sections that may take time. Hope this helps [1] http://git.ocamlcore.org/cgi-bin/gitweb.cgi?p=caravel/caravel.git;a=blob_plain;f=gtk_thread_bis/gtkThreadBis.ml;hb=67e29bc6550603fa42857569eb6f878f180949f2 [2] http://acid3.acidtests.org/ [3] http://ocsigen.org/lwt/doc/api/Lwt_glib.html -- Adrien Nader On 14/12/2010, Maxence Guesdon <[email protected]> wrote: > On Tue, 14 Dec 2010 08:36:26 +0100 > Maxence Guesdon <[email protected]> wrote: > >> Hello, >> >> When I use GtkThread.main (), my process consumes a lot of CPU. Having a >> look at the code of GtkThread.ml, I see a never ending loop, and >> especially >> a never-delaying loop, which I think results in the consumption. >> >> Is it normal ? Isn't there a way to use threads without such a consumption >> ? > > Well, I just saw that Adrien proposed a workaround/fix for this problem on > the list one year ago: > http://yquem.inria.fr/pipermail/lablgtk/2009-December/000335.html > > He changed > Thread.delay 0.0001; > into > Thread.delay 0.013; > > Could we integrate this ? And may be provide a function to change the delay > used in the fix ? > > Regards, > > Maxence > > > > _______________________________________________ > Lablgtk mailing list > [email protected] > http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk >