Re: Multithreaded gtk apps

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

 



On 14 January 2013 04:46, Andy Spencer <andy753421@xxxxxxxxx> wrote:
> run on win32. I would caution against overuse of g_idle_add though.
>
> Recently I've been saving off the data from the thread and then doing
> the GUI updates at the start of the next expose/draw.

I generally do both. I like:

* a background thread finishes some task and calls g_idle_add_full()
with high priority to send the result to the main thread
* the main thread runs the idle callback and uses the data to update
the program model
* the program model queues a view refresh for every part of the model
that changes with a low priority g_idle_add_full()
* the views update from the model and (eventually) turn into an expose/draw

The idea is to decouple model updates from drawing, so under load your
program just updates the display less frequently, it never drops data
or lags.

Different structures will suit different programs, of course.

John
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux